CN109104374B - Method and device for realizing synchronous issuing strategy - Google Patents

Method and device for realizing synchronous issuing strategy Download PDF

Info

Publication number
CN109104374B
CN109104374B CN201810821816.9A CN201810821816A CN109104374B CN 109104374 B CN109104374 B CN 109104374B CN 201810821816 A CN201810821816 A CN 201810821816A CN 109104374 B CN109104374 B CN 109104374B
Authority
CN
China
Prior art keywords
message
identification code
unique identification
strategy
universal unique
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.)
Active
Application number
CN201810821816.9A
Other languages
Chinese (zh)
Other versions
CN109104374A (en
Inventor
李红雷
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhengzhou Yunhai Information Technology Co Ltd
Original Assignee
Zhengzhou Yunhai Information Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Zhengzhou Yunhai Information Technology Co Ltd filed Critical Zhengzhou Yunhai Information Technology Co Ltd
Priority to CN201810821816.9A priority Critical patent/CN109104374B/en
Publication of CN109104374A publication Critical patent/CN109104374A/en
Application granted granted Critical
Publication of CN109104374B publication Critical patent/CN109104374B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/24Traffic characterised by specific attributes, e.g. priority or QoS
    • H04L47/2425Traffic characterised by specific attributes, e.g. priority or QoS for supporting services specification, e.g. SLA
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • H04L67/568Storing data temporarily at an intermediate stage, e.g. caching

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)
  • Computer And Data Communications (AREA)

Abstract

The invention discloses a method for realizing synchronous issuing strategy, which comprises the following steps: generating a universal unique identification code according to the issuing strategy; generating a blocking queue when issuing the strategy, and putting the blocking queue into a Hash mapping, wherein the secret key is a universal unique identification code; after receiving the message, writing the message into a blocking queue according to the universal unique identification code; and deleting the message data of which the key is the universal unique identification code after the message is taken from the blocking queue. And the device for realizing the synchronous issuing strategy is also disclosed, the rabbitmq data transmission in the whole process is in an asynchronous form, and a synchronous process is changed through a blocking queue. The mode not only ensures the synchronism, but also does not lose the efficiency of asynchronous transmission.

Description

Method and device for realizing synchronous issuing strategy
Technical Field
The invention relates to the technical field of message strategy selection, in particular to a method and a device for realizing synchronous issuing of strategies.
Background
With the development of SSR services, the strategy issuing mode is diversified, and the originally used rabbitmq asynchronous message issuing mode is realized. Some strategies are more strict in issuing requirements, and the client needs to synchronously return an execution result, for example, the issuing strategy needs the client to return the receiving condition, the execution condition, the client state acquisition and the like of the strategy, and if the strategy fails, the strategy needs to be issued again and the like, the current mode cannot be realized.
Disclosure of Invention
The invention aims to provide a method and a device for realizing a synchronous issuing strategy, which not only ensure the synchronism, but also keep the efficiency of asynchronous transmission.
In order to achieve the purpose, the invention adopts the following technical scheme:
the first aspect of the present invention provides a method for implementing a synchronous issuing strategy, which comprises the following steps:
generating a universal unique identification code according to the issuing strategy;
generating a blocking queue when issuing the strategy, and putting the blocking queue into a Hash mapping, wherein the secret key is a universal unique identification code;
after receiving the message, writing the message into a blocking queue according to the universal unique identification code;
and deleting the message data of which the key is the universal unique identification code after the message is taken from the blocking queue.
With reference to the first aspect, in a first possible implementation manner of the first aspect, the generating a universal unique identifier according to an issued policy includes:
generating a globally unique universal unique identification code according to the issued strategy, using the globally unique universal unique identification code as an information identifier register to be placed in a strategy message header, generating a strategy message body in a json format according to the content of the strategy message, and sending the strategy message body to a rabbitmq queue.
With reference to the first aspect, in a second possible implementation manner of the first aspect, the writing, after receiving the message, the result into a blocking queue according to the universal unique identifier includes:
and establishing monitoring aiming at a returned message queue of the client, and writing message data into a corresponding blocking queue according to the universal unique identification code after receiving the message.
With reference to the first aspect, in a third possible implementation manner of the first aspect, the deleting, after the message is fetched from the congestion queue, message data whose key is a universal unique identifier includes:
using poll to fetch information from the blocking queue, if no information exists, waiting all the time;
and if the message is taken, deleting the data of which the key is the universal unique identification code from the thread safety hash table.
With reference to the first aspect, in a fourth possible implementation manner of the first aspect, the fetching a message from a congestion queue using poll, if there is no message, the method includes:
and taking a message from the blocking queue by using poll, setting a timeout time as a waiting time, and considering that the request has no response failure if no message is received after the waiting time is exceeded.
The second aspect of the present invention provides a device for implementing a synchronous issuing policy, including:
the universal unique identification code generating module generates a universal unique identification code according to the issuing strategy;
the blocking queue generating module generates a blocking queue when issuing the strategy and puts the blocking queue into the Hash mapping, wherein the secret key is a universal unique identification code;
the message monitoring module is used for establishing monitoring aiming at a message queue returned by the client, and writing message data into a corresponding blocking queue according to the universal unique identification code after receiving the message;
and the message taking-out module is used for deleting the message data of which the key is the universal unique identification code after taking the message from the blocking queue.
The apparatus for implementing a synchronous issuing policy of the second aspect of the present invention can implement the methods of the first aspect and the implementation manners of the first aspect, and achieve the same effects.
The effect provided in the summary of the invention is only the effect of the embodiment, not all the effects of the invention, and one of the above technical solutions has the following advantages or beneficial effects:
the invention is used on the basis of rabbitmq asynchronous transmission, and the external program ensures the message synchronism, thereby not only ensuring the synchronism, but also not losing the efficiency of asynchronous transmission; uniquely determining a message by using the message uuid, and generating the message when the message is sent; implementing synchronization using a blocking queue; the communication is fast and efficient, socket communication based on TCP is achieved by using the rabbitmq as the middleware, and the efficiency is higher than that of a traditional HTTP communication mode; the reliability is high, the data loss can not occur, and the message reliability in data transmission is ensured by relying on the message queue function of the rabbitmq.
Drawings
FIG. 1 is a flowchart of an embodiment of a method for implementing a synchronous issue policy;
FIG. 2 is a flowchart of an embodiment of a method for implementing a synchronous issue policy;
fig. 3 is a schematic structural diagram of a device for implementing synchronous issuing of a policy according to the present invention.
Detailed Description
In order to clearly explain the technical features of the present invention, the following detailed description of the present invention is provided with reference to the accompanying drawings. The following disclosure provides many different embodiments, or examples, for implementing different features of the invention. To simplify the disclosure of the present invention, the components and arrangements of specific examples are described below. Furthermore, the present invention may repeat reference numerals and/or letters in the various examples. This repetition is for the purpose of simplicity and clarity and does not in itself dictate a relationship between the various embodiments and/or configurations discussed. It should be noted that the components illustrated in the figures are not necessarily drawn to scale. Descriptions of well-known components and processing techniques and procedures are omitted so as to not unnecessarily limit the invention.
Example one
As shown in fig. 1, a method for implementing a synchronous issuing policy includes the following steps:
s1, generating a universal unique identification code according to the issued strategy;
s2, generating a blocking queue when issuing the strategy, and putting the blocking queue into a Hash map, wherein the secret key is a universal unique identification code;
s3, writing the message into a blocking queue according to the universal unique identification code after receiving the message;
and S4, deleting the message data of which the key is the universal unique identification code after the message is taken from the blocking queue.
Example two
As shown in fig. 2, a method for implementing a synchronous issuing policy includes the following steps:
s1, generating a globally unique universal unique identification code according to the issued strategy, placing the universally unique identification code as an information identifier register in a strategy message header, generating a strategy message body in a json format according to the content of the strategy message, and sending the strategy message body to a rabbitmq queue.
And S2, generating a blocking queue when issuing the strategy, and putting the blocking queue into the hash mapping, wherein the secret key is a universal unique identification code.
And S3, monitoring is established aiming at the message queue returned by the client, and after the message is received, the message data is written into the corresponding blocking queue according to the universal unique identification code.
And S4, using poll to fetch the message from the blocking queue, if no message exists, waiting all the time, and if the message is fetched, deleting the data of which the key is the universal unique identification code from the thread safety hash table.
And taking a message from the blocking queue by using poll, setting a timeout time as a waiting time, and considering that the request has no response failure if no message is received after the waiting time is exceeded. The present embodiment sets a 30 second timeout. If the message is taken, the data with key as UUID is deleted from the Concurrent Hash Map (thread safe Hash table). The rabbitmq data transmission in the whole process is in an asynchronous mode, and becomes a synchronous process through a blocking queue. The mode not only ensures the synchronism, but also does not lose the efficiency of asynchronous transmission.
As shown in fig. 3, an apparatus for implementing a synchronous issuing policy includes:
the universal unique identification code generating module 101 generates a universal unique identification code according to the issued strategy;
the blocking queue generating module 102 generates a blocking queue when issuing a policy, and puts the blocking queue into a hash map, wherein a secret key is a universal unique identification code;
the message monitoring module 103 establishes monitoring for a message queue returned by the client, and writes message data into a corresponding blocking queue according to the universal unique identification code after receiving the message;
and the message extracting module 104 is used for deleting the message data of which the key is the universal unique identification code after extracting the message from the blocking queue.
Although the embodiments of the present invention have been described with reference to the accompanying drawings, it is not intended to limit the scope of the present invention, and it should be understood by those skilled in the art that various modifications and variations can be made without inventive efforts by those skilled in the art based on the technical solution of the present invention.

Claims (3)

1. A method for realizing synchronous issuing strategy is characterized by comprising the following steps:
generating a universal unique identification code according to the issuing strategy;
the generating of the universal unique identification code according to the issued strategy comprises the following steps:
generating a globally unique universal unique identification code according to the issued strategy, using the globally unique universal unique identification code as an information identifier register to be placed in a strategy message header, generating a strategy message body in a json format according to the content of the strategy message, and sending the strategy message body to a rabbitmq queue;
generating a blocking queue when issuing a strategy, and putting the blocking queue into a Hash mapping, wherein a secret key is a universal unique identification code;
after receiving the message, writing the message into a blocking queue according to the universal unique identification code;
writing the message into a blocking queue according to the universal unique identification code after receiving the message, including:
establishing monitoring aiming at a returned message queue of a client, and writing received message data into a corresponding blocking queue according to a universal unique identification code after receiving a message;
deleting the message data of which the key is the universal unique identification code after the message is taken from the blocking queue;
the deleting the message data of which the key is the universal unique identification code after the message is taken from the blocking queue comprises the following steps:
using poll to fetch information from the blocking queue, if no information exists, waiting all the time;
and if the message is taken, deleting the data of which the key is the universal unique identification code from the thread safety hash table.
2. The method of claim 1, wherein said using poll from the congestion queue to fetch messages if there are no messages to wait comprises:
and taking a message from the blocking queue by using poll, setting a timeout time as a waiting time, and considering that the request has no response failure if no message is received after the waiting time is exceeded.
3. A device for realizing synchronous issuing strategy is characterized by comprising:
the universal unique identification code generating module generates a universal unique identification code according to the issuing strategy;
the generating of the universal unique identification code according to the issued strategy comprises the following steps:
generating a globally unique universal unique identification code according to the issued strategy, using the globally unique universal unique identification code as an information identifier register to be placed in a strategy message header, generating a strategy message body in a json format according to the content of the strategy message, and sending the strategy message body to a rabbitmq queue;
the blocking queue generating module generates a blocking queue when issuing the strategy, and puts the blocking queue into a Hash mapping, wherein the secret key is a universal unique identification code;
the message monitoring module is used for establishing monitoring aiming at a message queue returned by the client, and writing received message data into a corresponding blocking queue according to the universal unique identification code after receiving the message;
writing the message into a blocking queue according to the universal unique identification code after receiving the message, including:
establishing monitoring aiming at a returned message queue of a client, and writing received message data into a corresponding blocking queue according to a universal unique identification code after receiving a message;
and the message taking-out module is used for deleting the message data of which the key is the universal unique identification code after taking the message from the blocking queue.
CN201810821816.9A 2018-07-24 2018-07-24 Method and device for realizing synchronous issuing strategy Active CN109104374B (en)

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 CN109104374A (en) 2018-12-28
CN109104374B true 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)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112422539B (en) * 2020-11-08 2023-01-24 国家电网有限公司 Strategy synchronous issuing method based on message queue

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030182464A1 (en) * 2002-02-15 2003-09-25 Hamilton Thomas E. Management of message queues
CN102739391B (en) * 2012-06-13 2015-04-08 烽火通信科技股份有限公司 Method for realizing synchronization command based on asynchronous communication

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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

Also Published As

Publication number Publication date
CN109104374A (en) 2018-12-28

Similar Documents

Publication Publication Date Title
WO2021121370A1 (en) Message loss detection method and apparatus for message queue
EP3000217B1 (en) Electronic device using logical channels for communication
CN104077521B (en) Information processing method and device
WO2020207091A1 (en) Management client, and device monitoring system and method
US10742693B2 (en) Method and system for writing trajectory synchronization among multiple clients
US8407530B2 (en) Server reachability detection
US11108890B2 (en) Management client and device monitoring
CN110704265A (en) Early warning information active reporting method and system based on Modbus protocol
CN105786592A (en) Method and device for processing distributed transactions
CN104954101B (en) Multiple terminals method of data synchronization based on synchronous ACK
CN100450105C (en) Synchronous information interface realizing method based on JAVA information service
CN109104374B (en) Method and device for realizing synchronous issuing strategy
CN104866528A (en) Multi-platform data acquisition method and system
EP4128651A1 (en) Hardware security module proxy device for storage expansion
CN106293970B (en) Asynchronous processing method and system between a kind of process based on IPC
CN113037834A (en) Web page state updating method and device based on distributed instant push
CN111327680A (en) Authentication data synchronization method, device, system, computer equipment and storage medium
CN109766347B (en) Data updating method, device, system, computer equipment and storage medium
CN110022332B (en) Hypertext transfer security protocol proxy method, device, equipment and medium
CN114500243B (en) Data communication method, device, computer readable medium and electronic equipment
CN110417912B (en) Method for calling back after file downloading is completed
CN114116375A (en) Data transmission method and device based on PLDM protocol
CN110008032B (en) Communication mode realization method and electronic equipment
CN116016473A (en) Instance information acquisition method and system
CN107506491B (en) OSD data distribution method and device of distributed file system

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