CN109104374A - A kind of method and device for realizing synchronous distributing policy - Google Patents
A kind of method and device for realizing synchronous distributing policy Download PDFInfo
- Publication number
- CN109104374A CN109104374A CN201810821816.9A CN201810821816A CN109104374A CN 109104374 A CN109104374 A CN 109104374A CN 201810821816 A CN201810821816 A CN 201810821816A CN 109104374 A CN109104374 A CN 109104374A
- Authority
- CN
- China
- Prior art keywords
- message
- unique identifier
- queue
- universally unique
- policy
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L47/00—Traffic control in data switching networks
- H04L47/10—Flow control; Congestion control
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L47/00—Traffic control in data switching networks
- H04L47/10—Flow control; Congestion control
- H04L47/24—Traffic characterised by specific attributes, e.g. priority or QoS
- H04L47/2425—Traffic characterised by specific attributes, e.g. priority or QoS for supporting services specification, e.g. SLA
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/50—Network services
- H04L67/56—Provisioning of proxy services
- H04L67/568—Storing data temporarily at an intermediate stage, e.g. caching
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer And Data Communications (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
The invention discloses a kind of methods for realizing synchronous distributing policy, comprising the following steps: generates Universally Unique Identifier according to distributing policy;An obstruction queue is generated when distributing policy, is put into Hash mapping, key is Universally Unique Identifier;Message is written in obstruction queue according to Universally Unique Identifier after receiving message;The message data that key is Universally Unique Identifier is deleted after taking message from obstruction queue.A kind of device for realizing synchronous distributing policy is also disclosed, the transmission of rabbitmq data is asynchronous form in whole process, becomes a synchronizing process by blocking queue.This mode not only ensure that synchronism, but also not lose the efficiency of asynchronous transmission.
Description
Technical field
The present invention relates to message policies selection technique field, especially a kind of method and dress for realizing synchronous distributing policy
It sets.
Background technique
With the development of SSR business, tactful issues mode diversification, is used under rabbitmq asynchronous message originally
Originating party formula is realized.The requirement of some policy distributions is tightened up, and client synchronization is needed to return to implementing result, and for example distributing policy needs
Client returns to the reception condition of strategy, and executive condition obtains client state etc., if needing to re-issue after failure,
Current mode cannot achieve.
Summary of the invention
The object of the present invention is to provide a kind of method and devices for realizing synchronous distributing policy, not only ensure that synchronism, but also
The efficiency of asynchronous transmission is not lost.
To achieve the above object, the present invention adopts the following technical solutions:
First aspect present invention provides a kind of method for realizing synchronous distributing policy, comprising the following steps:
Universally Unique Identifier is generated according to distributing policy;
An obstruction queue is generated when distributing policy, is put into Hash mapping, key is Universally Unique Identifier;
Message is written in obstruction queue according to Universally Unique Identifier after receiving message;
The message data that key is Universally Unique Identifier is deleted after taking message from obstruction queue.
With reference to first aspect, in a first possible implementation of that first aspect, described generated according to distributing policy is led to
With unique identifier, comprising:
Globally unique Universally Unique Identifier is generated according to distributing policy, is placed on strategy as information identifier register
In message header, the policy message body of json format is generated according to policy message content, is sent in rabbitmq queue.
With reference to first aspect, in a second possible implementation of that first aspect, described to receive after message according to logical
It is write the result into obstruction queue with unique identifier, comprising:
Message queue is returned for client establish and monitor, after receiving message, according to Universally Unique Identifier by message
In the corresponding obstruction queue of data write-in.
With reference to first aspect, in first aspect in the third possible implementation, it is described from obstruction queue take message after
Delete the message data that key is Universally Unique Identifier, comprising:
Message is taken using poll from obstruction queue, if can wait always without message;
If get message deletes the data that key is Universally Unique Identifier from the Hash table of thread-safe.
With reference to first aspect, described to be used from obstruction queue in the 4th kind of possible implementation of first aspect
Poll takes message, if can wait always without message, comprising:
Message is taken using poll from obstruction queue, a time-out time is set as the waiting time, is more than the waiting time
It is not received by message, it is believed that this request fails without response.
Second aspect of the present invention provides a kind of device for realizing synchronous distributing policy, comprising:
Universally Unique Identifier generation module generates Universally Unique Identifier according to distributing policy;
Block queue generation module, an obstruction queue is generated when distributing policy, is put into Hash mapping, key is general
Unique identifier;
Message monitors module, returns to message queue for client and establishes monitoring, after receiving message, according to general unique
Corresponding obstruction queue is written in message data by identification code;
Message takes out module, deletes the message data that key is Universally Unique Identifier after taking message from obstruction queue.
The device of the synchronous distributing policy of the realization of second aspect of the present invention can be realized first aspect and first aspect
Each implementation in method, and obtain identical effect.
The effect provided in summary of the invention is only the effect of embodiment, rather than invents all whole effects, above-mentioned
A technical solution in technical solution have the following advantages that or the utility model has the advantages that
Present invention use is guaranteed the synchronism of message by external program, both guaranteed on the basis of rabbitmq asynchronous transmission
Synchronism, and do not lose the efficiency of asynchronous transmission;A piece of news is uniquely determined using message uuid, message generates when sending;Make
It is realized and is synchronized with obstruction queue;Communication is high-efficient fastly to use rabbitmq as middleware inherently based on the socket of TCP
Communication, it is more high-efficient than traditional http communication mode;The case where high reliablity is not in loss of data relies on rabbitmq
The message queue function of itself ensure that the reliability of message in data transmission.
Detailed description of the invention
Fig. 1 is that the present invention realizes synchronous one flow chart of distributing policy embodiment of the method;
Fig. 2 is that the present invention realizes synchronous two flow chart of distributing policy embodiment of the method;
Fig. 3 is that the present invention realizes synchronous distributing policy apparatus structure schematic diagram.
Specific embodiment
In order to clarify the technical characteristics of the invention, below by specific embodiment, and its attached drawing is combined, to this hair
It is bright to be described in detail.Following disclosure provides many different embodiments or example is used to realize different knots of the invention
Structure.In order to simplify disclosure of the invention, hereinafter the component of specific examples and setting are described.In addition, the present invention can be with
Repeat reference numerals and/or letter in different examples.This repetition is that for purposes of simplicity and clarity, itself is not indicated
Relationship between various embodiments and/or setting is discussed.It should be noted that illustrated component is not necessarily to scale in the accompanying drawings
It draws.Present invention omits the descriptions to known assemblies and treatment technology and process to avoid the present invention is unnecessarily limiting.
Embodiment one
As shown in Figure 1, a kind of method for realizing synchronous distributing policy, comprising the following steps:
S1, Universally Unique Identifier is generated according to distributing policy;
An obstruction queue is generated when S2, distributing policy, is put into Hash mapping, key is Universally Unique Identifier;
S3, message is written in obstruction queue according to Universally Unique Identifier after receiving message;
S4, the message data that key is Universally Unique Identifier is deleted after taking message from obstruction queue.
Embodiment two
As shown in Fig. 2, a kind of method for realizing synchronous distributing policy, comprising the following steps:
S1, globally unique Universally Unique Identifier is generated according to distributing policy, be placed on as information identifier register
In policy message head, the policy message body of json format is generated according to policy message content, is sent in rabbitmq queue.
An obstruction queue is generated when S2, distributing policy, is put into Hash mapping, key is Universally Unique Identifier.
S3, message queue foundation monitoring is returned to for client, after receiving message, will be disappeared according to Universally Unique Identifier
It ceases in the corresponding obstruction queue of data write-in.
S4, using poll message is taken from obstruction queue, if can wait always without message, if getting message from line
The data that key is Universally Unique Identifier are deleted in the Hash table of Cheng Anquan.
Message is taken using poll from obstruction queue, a time-out time is set as the waiting time, is more than the waiting time
It is not received by message, it is believed that this request fails without response.30 seconds time-out time is arranged in the present embodiment.Disappear if got
Cease the data for deleting that key is UUID from Concurrent Hash Map (Hash table of thread-safe).In whole process
The transmission of rabbitmq data is asynchronous form, becomes a synchronizing process by blocking queue.This mode both ensure that together
Step property, and the efficiency of asynchronous transmission is not lost.
As shown in figure 3, a kind of device for realizing synchronous distributing policy, comprising:
Universally Unique Identifier generation module 101 generates Universally Unique Identifier according to distributing policy;
Block queue generation module 102, an obstruction queue is generated when distributing policy, is put into Hash mapping, key is
Universally Unique Identifier;
Message monitors module 103, returns to message queue for client and establishes monitoring, after receiving message, according to general
Corresponding obstruction queue is written in message data by unique identifier;
Message takes out module 104, deletes the message data that key is Universally Unique Identifier after taking message from obstruction queue.
Above-mentioned, although the foregoing specific embodiments of the present invention is described with reference to the accompanying drawings, not protects model to the present invention
The limitation enclosed, those skilled in the art should understand that, based on the technical solutions of the present invention, those skilled in the art are not
Need to make the creative labor the various modifications or changes that can be made still within protection scope of the present invention.
Claims (6)
1. a kind of method for realizing synchronous distributing policy, characterized in that the following steps are included:
Universally Unique Identifier is generated according to distributing policy;
An obstruction queue is generated when distributing policy, is put into Hash mapping, key is Universally Unique Identifier;
Message is written in obstruction queue according to Universally Unique Identifier after receiving message;
The message data that key is Universally Unique Identifier is deleted after taking message from obstruction queue.
2. the method as described in claim 1, characterized in that described to generate Universally Unique Identifier according to distributing policy, comprising:
Globally unique Universally Unique Identifier is generated according to distributing policy, is placed on policy message as information identifier register
In head, the policy message body of json format is generated according to policy message content, is sent in rabbitmq queue.
3. the method as described in claim 1, characterized in that described to receive result after message according to Universally Unique Identifier
In write-in obstruction queue, comprising:
Message queue is returned for client establish and monitor, after receiving message, according to Universally Unique Identifier by message data
In the corresponding obstruction queue of write-in.
4. the method as described in claim 1, characterized in that described to take that delete key after message be general unique from obstruction queue
The message data of identification code, comprising:
Message is taken using poll from obstruction queue, if can wait always without message;
If get message deletes the data that key is Universally Unique Identifier from the Hash table of thread-safe.
5. method as claimed in claim 4, characterized in that it is described to take message using poll from obstruction queue, if do not had
Message can wait always, comprising:
Message is taken using poll from obstruction queue, a time-out time is set as the waiting time, is not had more than the waiting time
Receive message, it is believed that this request fails without response.
6. a kind of device for realizing synchronous distributing policy, characterized in that include:
Universally Unique Identifier generation module generates Universally Unique Identifier according to distributing policy;
Block queue generation module, an obstruction queue generated when distributing policy, is put into Hash mapping, key be it is general uniquely
Identification code;
Message monitors module, returns to message queue for client and establishes monitoring, after receiving message, according to general unique identification
Corresponding obstruction queue is written in message data by code;
Message takes out module, deletes the message data that key is Universally Unique Identifier after taking message from obstruction queue.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810821816.9A CN109104374B (en) | 2018-07-24 | 2018-07-24 | Method and device for realizing synchronous issuing strategy |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810821816.9A CN109104374B (en) | 2018-07-24 | 2018-07-24 | Method and device for realizing synchronous issuing strategy |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109104374A true CN109104374A (en) | 2018-12-28 |
CN109104374B CN109104374B (en) | 2022-02-18 |
Family
ID=64847309
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810821816.9A Active CN109104374B (en) | 2018-07-24 | 2018-07-24 | Method and device for realizing synchronous issuing strategy |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109104374B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112422539A (en) * | 2020-11-08 | 2021-02-26 | 国家电网有限公司 | Strategy synchronous issuing method based on message queue |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20030182464A1 (en) * | 2002-02-15 | 2003-09-25 | Hamilton Thomas E. | Management of message queues |
CN102739391A (en) * | 2012-06-13 | 2012-10-17 | 烽火通信科技股份有限公司 | Method for realizing synchronization command based on asynchronous communication |
CN102801737A (en) * | 2012-08-28 | 2012-11-28 | 北京城市网邻信息技术有限公司 | Asynchronous network communication method and device |
CN104391751A (en) * | 2014-10-16 | 2015-03-04 | 广州天宁信息技术有限公司 | Synchronization method and device for algorithmic data processing |
CN105516081A (en) * | 2015-11-25 | 2016-04-20 | 浪潮电子信息产业股份有限公司 | Method and system for issuing safety strategy by server and message queue middleware |
CN107506248A (en) * | 2017-08-16 | 2017-12-22 | 中国银行股份有限公司 | Synchronously turn the asynchronous means of communication and device in a kind of on-line system |
-
2018
- 2018-07-24 CN CN201810821816.9A patent/CN109104374B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20030182464A1 (en) * | 2002-02-15 | 2003-09-25 | Hamilton Thomas E. | Management of message queues |
CN102739391A (en) * | 2012-06-13 | 2012-10-17 | 烽火通信科技股份有限公司 | Method for realizing synchronization command based on asynchronous communication |
CN102801737A (en) * | 2012-08-28 | 2012-11-28 | 北京城市网邻信息技术有限公司 | Asynchronous network communication method and device |
CN104391751A (en) * | 2014-10-16 | 2015-03-04 | 广州天宁信息技术有限公司 | Synchronization method and device for algorithmic data processing |
CN105516081A (en) * | 2015-11-25 | 2016-04-20 | 浪潮电子信息产业股份有限公司 | Method and system for issuing safety strategy by server and message queue middleware |
CN107506248A (en) * | 2017-08-16 | 2017-12-22 | 中国银行股份有限公司 | Synchronously turn the asynchronous means of communication and device in a kind of on-line system |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112422539A (en) * | 2020-11-08 | 2021-02-26 | 国家电网有限公司 | Strategy synchronous issuing method based on message queue |
Also Published As
Publication number | Publication date |
---|---|
CN109104374B (en) | 2022-02-18 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
AU2014269271B2 (en) | Electronic device using logical channels for communication | |
WO2017107732A1 (en) | Login status synchronization method and system | |
ES2954995T3 (en) | Method and system to synchronize the writing path of multiple clients | |
CN102843436B (en) | A kind of device management method, equipment, server and system | |
CN108712457A (en) | Back-end server dynamic load method of adjustment and device based on Nginx reverse proxys | |
CN103617255B (en) | A kind of business datum for power information system exchanges and synchronizes system and method | |
CN103457911A (en) | Method and system of information sharing | |
CN104917833A (en) | Asynchronous information processing method based on NIO request | |
CN110309231A (en) | A kind of method of data synchronization and system across computer room | |
CN101335723A (en) | Instant communication system, window establishing method and system | |
CN100450105C (en) | Synchronous information interface realizing method based on JAVA information service | |
CN103037195A (en) | Method and device used for setting video call parameters and transmission capacity parameters | |
CN103369034A (en) | Method, system and device for sending photos to digital photo frames | |
CN109104374A (en) | A kind of method and device for realizing synchronous distributing policy | |
CN102594874B (en) | Synchronization processing method and device | |
CN103220343B (en) | Big data multi-system retransmission method | |
CN106559236B (en) | Equipment resource management method and device of service board, main control board and frame type equipment | |
CN109831404B (en) | Instant communication system and method compatible with multiple terminals | |
CN108307416B (en) | Internet of things terminal management method | |
CN106657135A (en) | File transfer method and equipment based on SSL (Secure Socket Layer) protocol authentication | |
CN104796458A (en) | Information fusion method for Android system | |
CN105357234A (en) | Wireless data card, communication system, and data synchronization method | |
CN103490898B (en) | E-mail collection authorization method, device and system | |
CN109274774A (en) | A kind of date storage method, device and computer readable storage medium | |
CN107872479B (en) | Cloud management platform and controller integration method and system and related modules |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |