CN106250250A - Data communications method and device - Google Patents
Data communications method and device Download PDFInfo
- Publication number
- CN106250250A CN106250250A CN201610651790.9A CN201610651790A CN106250250A CN 106250250 A CN106250250 A CN 106250250A CN 201610651790 A CN201610651790 A CN 201610651790A CN 106250250 A CN106250250 A CN 106250250A
- Authority
- CN
- China
- Prior art keywords
- message
- delay
- queue
- retries
- switching unit
- 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.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/546—Message passing systems or structures, e.g. queues
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2209/00—Indexing scheme relating to G06F9/00
- G06F2209/54—Indexing scheme relating to G06F9/54
- G06F2209/548—Queue
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Telephonic Communication Services (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
The invention discloses a kind of data communications method, described data communications method includes step: receive the state value that the message of customer end transmission is corresponding, wherein, described customer end when carrying out business logic processing and completing to message, returning the state value of result, described state value includes successfully, tries again later, unsuccessfully abandons;When described state value is for trying again later, calls delay message switching unit and send the message to the delayed message queue that described delay message switching unit is corresponding;After lasting the predetermined time delay that described delayed message queue is corresponding, send the message to retry message queue.The present invention also proposes a kind of data communication equipment.The present invention improves the Message Processing efficiency of Message Queuing server.
Description
Technical field
The present invention relates to computer communication technology field, particularly relate to a kind of data communications method and device.
Background technology
Message Queuing system RabbitMQ (Rabbit Message Queue) includes Message Queuing server RabbitMQ
Server and customer end RabbitMQ Client, wherein, is configured with message queue Queue in Message Queuing server.Disappear
Message, when message carrying out consumption and processing, is stored in message queue by breath queue server, disappears for customer end afterwards
Take the message in message queue.Owing to message may be consumed successfully, it is also possible to consume unsuccessfully, when information consumption failure,
Customer end can send a message to Message Queuing server, and Message Queuing server is receiving consumption failure
Time, immediately this consumption failure is delivered to again customer end and proceeds consumption process, until this information consumption
Successful, this will result in and this message carries out repeatedly consumption process always, and during this, the consumption of other message processes and is just subject to
Hindering, the Message Processing causing Message Queuing server is inefficient.
Summary of the invention
Present invention is primarily targeted at a kind of data communications method of offer and device, it is intended to solve Message Queuing server
The inefficient technical problem of Message Processing.
For achieving the above object, the present invention provides a kind of data communications method, and described data communications method includes following step
Rapid:
Receiving the state value that the message of customer end transmission is corresponding, wherein, message is being carried out by described customer end
When business logic processing completes, returning the state value of result, described state value includes successfully, tries again later, unsuccessfully abandons;
When described state value is for trying again later, calls delay message switching unit and send the message to described delay and disappear
The delayed message queue that breath switch is corresponding;
After lasting the predetermined time delay that described delayed message queue is corresponding, send the message to retry message team
Row.
Preferably, before the step of state value corresponding to message that described reception customer end sends, also include:
Send the message to described customer end, for described customer end, described message is carried out business and patrol
Collect and process, and returned the state value of result by call back function;
Described when described state value is for trying again later, call delay message switching unit send the message to described in prolong
The step of the delayed message queue that message switching unit is corresponding includes late:
When described state value is for trying again later, the number of retries arranged according to the message header of described message, select described
The delay switch that message is to be beamed back, and described message is beamed back the described delay message switching unit of selection;
Call the delay that described delay message switching unit sends the message to described delay message switching unit corresponding to disappear
Breath queue.
Preferably, described when described state value is for trying again later, retry time according to what the message header of described message was arranged
Number, the step postponing switch selecting described message to be beamed back includes:
When described state value is for trying again later, it is judged that whether the number of retries that the message header of described message is arranged is less than pre-
If number of retries threshold value;
When described number of retries is less than described number of retries threshold value, described message is selected to send out according to described number of retries
The delay switch returned.
Preferably, described when described state value is for trying again later, it is judged that what the message header of described message was arranged retries secondary
After whether number is less than the step of the number of retries threshold value preset, also include:
When described number of retries is more than described number of retries threshold value, send the message to dead letter message queue.
Preferably, described after lasting the predetermined time delay that described delayed message queue is corresponding, described message is sent
Include to the step retrying message queue:
After lasting the predetermined time delay that described delayed message queue is corresponding, send the message to described delay and disappear
What breath queue was corresponding retries message switching unit, and retry described in passing through message switching unit send the message to described in retry and disappear
Breath queue.
Additionally, for achieving the above object, the present invention also proposes a kind of data communication equipment, described data communication equipment bag
Include:
Receiver module, for receiving the state value that the message of customer end transmission is corresponding, wherein, described customer end
When message carrying out business logic processing and completing, returning the state value of result, described state value includes successfully, weighs after a while
Try, unsuccessfully abandon;
Sending module, for when described state value is for trying again later, calls delay message switching unit and described message is sent out
Deliver to the delayed message queue that described delay message switching unit is corresponding;
Processing module, for after lasting the predetermined time delay that described delayed message queue is corresponding, sends out described message
Deliver to retry message queue.
Preferably, described sending module is additionally operable to:
Send the message to described customer end, for described customer end, described message is carried out business and patrol
Collect and process, and returned the state value of result by call back function;
And when described state value is for trying again later, the number of retries arranged according to the message header of described message, select
The delay switch that described message is to be beamed back, beams back described message the described delay message switching unit of selection, and calls described
Postpone message switching unit and send the message to the delayed message queue that described delay message switching unit is corresponding.
Preferably, described sending module includes:
Judging unit, for when described state value is for trying again later, it is judged that what the message header of described message was arranged retries
Whether number of times is less than the number of retries threshold value preset;
Select unit, for when described number of retries is less than described number of retries threshold value, selecting according to described number of retries
Select the delay switch that described message is to be beamed back.
Preferably, described sending module is additionally operable to:
When described number of retries is more than described number of retries threshold value, send the message to dead letter message queue.
Preferably, described processing module is used for:
After lasting the predetermined time delay that described delayed message queue is corresponding, send the message to described delay and disappear
What breath queue was corresponding retries message switching unit, and retry described in passing through message switching unit send the message to described in retry and disappear
Breath queue.
The data communications method of present invention proposition and device, when the state that the message receiving the transmission of customer end is corresponding
When value is for trying again later, calls and postpone message switching unit and send the message to postpone the delay message team that message switching unit is corresponding
Row, and after lasting the predetermined time delay that this delayed message queue is corresponding, send the message to retry message queue, for disappearing
This message retried in message queue is consumed by expense client.Namely when information consumption failure, be not immediately to this
Message re-starts consumption again, until this information consumption success, but again this message is carried out after one period of time delay
Other message, within this time delay, can be carried out consumption process, this improves disappearing of Message Queuing server by consumption
Breath treatment effeciency.
Accompanying drawing explanation
Fig. 1 is the schematic flow sheet of data communications method first embodiment of the present invention;
Fig. 2 be in data communications method the second embodiment of the present invention when described state value is for trying again later, call delay
Message switching unit sends the message to the refinement flow process signal of delayed message queue corresponding to described delay message switching unit
Figure;
Fig. 3 is the high-level schematic functional block diagram of data communication equipment first embodiment of the present invention;
Fig. 4 is the refinement high-level schematic functional block diagram of sending module in data communication equipment the second embodiment of the present invention.
Detailed description of the invention
Should be appreciated that specific embodiment described herein, only in order to explain the present invention, is not intended to limit the present invention.
The present invention provides a kind of data communications method.It is data communications method first embodiment of the present invention with reference to Fig. 1, Fig. 1
Schematic flow sheet.In the present embodiment, described data communications method comprises the following steps:
Step S10, receives the state value that the message of customer end transmission is corresponding, and wherein, described customer end is right
Message carries out business logic processing when completing, and returns the state value of result, described state value includes successfully, tries again later,
Unsuccessfully abandon;
Message Queuing system RabbitMQ (Rabbit Message Queue) includes Message Queuing server RabbitMQ
Server and customer end RabbitMQ Client, wherein, is configured with in Message Queuing server RabbitMQ Server
Postpone message switching unit Delay Exchange, retry message switching unit Redelivery Exchange, delayed message queue
Delay Queue, retry message queue Retry Queue, dead letter message queue Dead Letter Queue etc..As consumption visitor
When family end RabbitMQ Client carries out business logic processing to the message in Message Queuing server RabbitMQ Server,
May consume successfully, it is also possible to failure can be consumed.When message being carried out business logic processing and completing, customer end
RabbitMQ Client returns to Message Queuing server RabbitMQ Server and message is carried out business logic processing result
State value.Wherein, the state value that message carries out business logic processing result includes successfully, tries again later, unsuccessfully abandons
Deng.Such as, when customer end RabbitMQ Client consumes message failure, customer end RabbitMQ Client will
This message sends to Message Queuing server RabbitMQ Server, and returns to Message Queuing server RabbitMQ Server
Return the state value tried again later.Message Queuing server RabbitMQ Server receives customer end RabbitMQ Client
The message sent and the state value that message is carried out business logic processing result.
Step S20, when described state value is for trying again later, calls delay message switching unit and sends the message to institute
State and postpone the delayed message queue that message switching unit is corresponding;
In the present embodiment, postpone message switching unit Delay Exchange and have with delayed message queue Delay Queue
The corresponding relation of binding.When Message Queuing server RabbitMQ Server receives customer end RabbitMQ Client
When message is carried out the state value of business logic processing result for trying again later of transmission, Message Queuing server RabbitMQ
Server calls delay message switching unit Delay Exchange and sends a message to postpone message switching unit Delay
Delayed message queue Delay Queue corresponding for Exchange.Wherein, delayed message queue Delay Queue is to there being one
Predetermined time delay.When not arriving time delay, the message in delayed message queue Delay Queue cannot be carried out extract,
Deliveries etc. process, and only when arriving time delay, could extract the message in delayed message queue Delay Queue.
Step S30, after lasting the predetermined time delay that described delayed message queue is corresponding, sends the message to weight
Examination message queue.
When Message Queuing server RabbitMQ Server calls delay message switching unit Delay Exchange, this is disappeared
Breath sends to postponing delayed message queue Delay Queue corresponding to message switching unit Delay Exchange, prolongs lasting this
After predetermined time delay the most corresponding for message queue Delay Queue, send the message to retry message queue Retry
Queue.In the present embodiment, acquiescence subscription retries message queue Retry Queue, when message sends to retrying message queue
After in Retry Queue, customer end RabbitMQ Client can obtain and consume this message.If this time this message
Also do not consume successfully, then customer end RabbitMQ Client can continue to Message Queuing server RabbitMQ Server
Sending this message and the state value tried again later, Message Queuing server RabbitMQ Server performs aforesaid operations again.
In the process, owing to message is just to send to retrying message queue Retry Queue after the time delay of one period,
During this, Message Queuing server RabbitMQ Server can carry out consumption and process operation other message.
Specifically, described step S30 includes:
Step a, after lasting the predetermined time delay that described delayed message queue is corresponding, sends the message to described
What delayed message queue was corresponding retry message switching unit, and retry message switching unit described in passing through and send the message to described
Retry message queue.
In the present embodiment, retry message switching unit Redelivery Exchange and delayed message queue Delay Queue
Foundation has binding relationship.When Message Queuing server RabbitMQ Server calls delay message switching unit Delay
Exchange sends the message to postpone delayed message queue Delay corresponding to message switching unit Delay Exchange
Queue, after lasting predetermined time delay corresponding to this delayed message queue Delay Queue, send the message to
What this delayed message queue Delay Queue had a binding relationship retries message switching unit Redelivery Exchange, by this
Retry message switching unit Redelivery Exchange and send the message to retry message queue Retry Queue, for afterwards
Customer end RabbitMQ Client obtains and consumes this message.
The scheme that the present embodiment provides, when receiving state value corresponding to message that customer end sends for trying again later
Time, call delay message switching unit and send the message to postpone the delayed message queue that message switching unit is corresponding, and lasting
After the predetermined time delay that this delayed message queue is corresponding, send the message to retry message queue, for customer end pair
This message retried in message queue is consumed.Namely when information consumption failure, be not immediately this message to be weighed again
Newly consume, until this information consumption success, but again this message is consumed after one period of time delay, prolong at this
In time late, other message can be carried out consumption process, this improves the Message Processing efficiency of Message Queuing server.
Meanwhile, also reduce the load of Message Queuing server, and complete the transition machine mould of customer end by retrying message queue
Type.
Further, as in figure 2 it is shown, propose data communications method the second embodiment of the present invention based on first embodiment.?
In second embodiment, before described step S10, also include:
Step b, sends the message to described customer end, carries out described message for described customer end
Business logic processing, and the state value of result is returned by call back function;
Described step S20 includes:
Step S21, when described state value is for trying again later, the number of retries arranged according to the message header of described message,
Select the delay message switching unit that described message is to be beamed back, and described message is beamed back the described delay message switching unit of selection;
Step S22, calls described delay message switching unit and sends the message to described delay message switching unit correspondence
Delayed message queue.
In the present embodiment, as customer end RabbitMQ Client Message Queuing server to be consumed RabbitMQ
During message in Server, Message Queuing server RabbitMQ Server sends a message to customer end RabbitMQ
Client, customer end RabbitMQ Client carry out business logic processing, and patrol message is carried out business this message
When volume process completes, returned to Message Queuing server RabbitMQ Server by call back function and message is carried out business patrol
Collect the state value of result.When consuming unsuccessfully, customer end RabbitMQ Client passes through call back function to message team
Row server RabbitMQ Server returns the state value and this message tried again later.Wherein, the message header of this message sets
It is equipped with the number of retries of message.
In the present embodiment, configurable multiple delay message switching units in Message Queuing server RabbitMQ Server
Delay Exchange, multiple retry message switching unit Redelivery Exchange and multiple delayed message queue Delay
Queue, wherein, one postpones a message switching unit Delay Exchange and delayed message queue Delay Queue and has
One-to-one relationship, a delayed message queue Delay Queue and one retry message switching unit Redelivery
Exchange sets up the one-to-one relationship having binding.Weigh after a while when Message Queuing server RabbitMQ Server receives
When the state value of examination and this message, the number of retries first arranged according to the message header of this message, select this message to be beamed back
Postpone switch Delay Exchange.Such as, when the number of retries that the message header in this message is arranged is 1, this message is selected
Delay switch Delay Exchange to be beamed back is Delay Exchange 1.Then, this message is beamed back prolonging of selection
Message switching unit Delay Exchange late, and it is corresponding to send the message to postpone message switching unit Delay Exchange
Delayed message queue Delay Queue.
Further, described step S21 includes:
Step c, when described state value is for trying again later, it is judged that whether the number of retries that the message header of described message is arranged
Less than the number of retries threshold value preset;
Step e, when described number of retries is less than described number of retries threshold value, disappears according to the selection of described number of retries
The delay switch that breath is to be beamed back.
Further, after described step c, also include:
Step e, when described number of retries is more than described number of retries threshold value, sends the message to dead letter message team
Row.
When again consuming message, message not necessarily can be consumed successfully, it is possible to or consume unsuccessfully, in order to avoid producing
The raw endless loop always consumed some message, in the present embodiment, is previously provided with a number of retries threshold of message
Value, such as, arranging this number of retries threshold value is 16, and this number of retries threshold value can be arranged flexibly according to practical situation,
This is not restricted.When Message Queuing server RabbitMQ Server receives the state value tried again later, determine whether
Whether the number of retries that the message header of this message is arranged is less than the number of retries threshold value preset.Message header in this message is arranged
When number of retries is less than number of retries threshold value, namely illustrate that the consumption number of times of this message is also few, now, disappearing according to this message
The number of retries that breath head is arranged selects the delay switch Delay Exchange that this message is to be beamed back, and this message is beamed back selection
Delay message switching unit Delay Exchange, and call delay message switching unit Delay Exchange this message is sent
To the delayed message queue Delay Queue that this delay message switching unit Delay Exchange is corresponding.Message header when message
When the number of retries arranged is more than number of retries threshold value, namely the consumption number of times of this message is described too much, now, in order to keep away
Exempt to enter the endless loop that this message carries out consumption process always, send the message to dead letter message queue Dead Letter
Queue.Dead letter message queue Dead Letter Queue meeting this consumption failure of persistence, later stage business monitoring can
Relevant treatment operations is carried out by extracting the consumption failure preserved in dead letter message queue Dead Letter Queue.
Further, configurable in Message Queuing server RabbitMQ Server multiple message queue Retry is retried
Queue, each retry message queue Retry Queue have correspondence retry message queue title Retry Queue name.
Further, carry correspondence in message retries message queue title Retry Queue name, when message sends to retrying message
After in switch Redelivery Exchange, retry message queue title Retry Queue according to what this message was carried
Name, send the message to this retry message queue title Retry Queue name corresponding retry message queue Retry
In Queue, obtain and consume this message for customer end RabbitMQ Client afterwards.
The scheme that the present embodiment proposes, the number of retries that the message header in message is arranged is less than the number of retries threshold value preset
Time, send the message to select delay message switching unit, and call this delay message switching unit send the message to right
The delayed message queue answered, re-starts consumption and processes this message, and the number of retries that the message header in message is arranged is more than pre-
If number of retries threshold value time, directly send the message to dead letter message queue, no longer this message carried out consumption process, keep away
Exempt to enter the endless loop process of unsuccessfully consumption, thus further increase the Message Processing efficiency of Message Queuing server.
The present invention further provides a kind of data communication equipment.It is data communication equipment first of the present invention with reference to Fig. 3, Fig. 3
The high-level schematic functional block diagram of embodiment.
In the present embodiment, described data communication equipment includes:
Receiver module 10, for receiving the state value that the message of customer end transmission is corresponding, wherein, described customer
End, when message carrying out business logic processing and completing, returns the state value of result, and described state value includes successfully, after a while
Retry, unsuccessfully abandon;
Message Queuing system RabbitMQ (Rabbit Message Queue) includes Message Queuing server RabbitMQ
Server and customer end RabbitMQ Client, wherein, is configured with in Message Queuing server RabbitMQ Server
Postpone message switching unit Delay Exchange, retry message switching unit Redelivery Exchange, delayed message queue
Delay Queue, retry message queue Retry Queue, dead letter message queue Dead Letter Queue etc..As consumption visitor
When family end RabbitMQ Client carries out business logic processing to the message in Message Queuing server RabbitMQ Server,
May consume successfully, it is also possible to failure can be consumed.When message being carried out business logic processing and completing, customer end
RabbitMQ Client returns to Message Queuing server RabbitMQ Server and message is carried out business logic processing result
State value.Wherein, the state value that message carries out business logic processing result includes successfully, tries again later, unsuccessfully abandons
Deng.Such as, when customer end RabbitMQ Client consumes message failure, customer end RabbitMQ Client will
This message sends to Message Queuing server RabbitMQ Server, and returns to Message Queuing server RabbitMQ Server
Return the state value tried again later.Receiver module 10 receives the message of customer end RabbitMQ Client transmission and offsets
Breath carries out the state value of business logic processing result.
Sending module 20, for when described state value is for trying again later, calls delay message switching unit by described message
Send the delayed message queue that extremely described delay message switching unit is corresponding;
In the present embodiment, postpone message switching unit Delay Exchange and have with delayed message queue Delay Queue
The corresponding relation of binding.When receiver module 10 receive customer end RabbitMQ Client send message is carried out industry
When the state value of business logical process result is for trying again later, sending module 20 calls delay message switching unit Delay Exchange
Send a message to postpone delayed message queue Delay Queue corresponding to message switching unit Delay Exchange.Wherein, prolong
Message queue Delay Queue is to there being a predetermined time delay late.When not arriving time delay, delayed message queue
Message in Delay Queue cannot be carried out extraction, delivery etc. and processes, and only when arriving time delay, could extract delay
Message in message queue Delay Queue.
Processing module 30, for after lasting the predetermined time delay that described delayed message queue is corresponding, by described message
Send to retrying message queue.
Send the message to postpone message friendship when sending module 20 calls delay message switching unit Delay Exchange
The delayed message queue Delay Queue changing planes corresponding for Delay Exchange, is lasting this delayed message queue Delay
After the predetermined time delay that Queue is corresponding, processing module 30 sends the message to retry message queue Retry Queue.
In the present embodiment, acquiescence subscription retries message queue Retry Queue, when message sends to retrying message queue Retry
After in Queue, customer end RabbitMQ Client can obtain and consume this message.If this time this message does not also disappear
Take successfully, then customer end RabbitMQ Client can continue to send to Message Queuing server RabbitMQ Server to be somebody's turn to do
Message and the state value tried again later, sending module 20 performs aforesaid operations again.In the process, due to message be through
Just sending to retrying message queue Retry Queue after the time delay of one period, during this period, processing module 30 can be to it
His message carries out consumption and processes operation.
Specifically, described processing module 30 is used for:
After lasting the predetermined time delay that described delayed message queue is corresponding, send the message to described delay and disappear
What breath queue was corresponding retries message switching unit, and retry described in passing through message switching unit send the message to described in retry and disappear
Breath queue.
In the present embodiment, retry message switching unit Redelivery Exchange and delayed message queue Delay Queue
Foundation has binding relationship.Send the message to postpone when sending module 20 calls delay message switching unit Delay Exchange
Delayed message queue Delay Queue corresponding for message switching unit Delay Exchange, is lasting this delayed message queue
After the predetermined time delay that Delay Queue is corresponding, processing module 30 sends the message to and this delayed message queue
What Delay Queue had a binding relationship retries message switching unit Redelivery Exchange, retries message switching unit by this
Redelivery Exchange sends the message to retry message queue Retry Queue, for customer end afterwards
RabbitMQ Client obtains and consumes this message.
The scheme that the present embodiment provides, when receiver module 10 receives state value corresponding to message that customer end sends
During for trying again later, sending module 20 calls delay message switching unit and sends the message to postpone corresponding the prolonging of message switching unit
Message queue late, and after lasting the predetermined time delay that this delayed message queue is corresponding, this message is sent by processing module 30
To retrying message queue, for consumption family end, this message retried in message queue is consumed.Namely in information consumption failure
Time, it is not immediately this message to be re-started consumption again, until this information consumption success, but through one period of time delay
After again this message is consumed, within this time delay, other message can be carried out consumption process, this improves and disappear
The Message Processing efficiency of breath queue server.Meanwhile, also reduce the load of Message Queuing server, and by retrying message team
Arrange the transition machine model of customer end.
Further, based on first embodiment, data communication equipment the second embodiment of the present invention is proposed.In the second embodiment
In, described sending module 20 is additionally operable to:
Send the message to described customer end, for described customer end, described message is carried out business and patrol
Collect and process, and returned the state value of result by call back function;
And when described state value is for trying again later, the number of retries arranged according to the message header of described message, select
The delay switch that described message is to be beamed back, beams back described message the described delay message switching unit of selection, and calls described
Postpone message switching unit and send the message to the delayed message queue that described delay message switching unit is corresponding.
In the present embodiment, as customer end RabbitMQ Client Message Queuing server to be consumed RabbitMQ
During message in Server, sending module 20 sends a message to customer end RabbitMQ Client, customer end
RabbitMQ Client carries out business logic processing to this message, and when message carrying out business logic processing and completing, passes through
Call back function returns the state that message carries out business logic processing result to Message Queuing server RabbitMQ Server
Value.When consuming unsuccessfully, customer end RabbitMQ Client passes through call back function to Message Queuing server RabbitMQ
Server returns the state value and this message tried again later.Wherein, the message header of this message is provided with retrying of message secondary
Number.
In the present embodiment, configurable multiple delay message switching units in Message Queuing server RabbitMQ Server
Delay Exchange, multiple retry message switching unit Redelivery Exchange and multiple delayed message queue Delay
Queue, wherein, one postpones a message switching unit Delay Exchange and delayed message queue Delay Queue and has
One-to-one relationship, a delayed message queue Delay Queue and one retry message switching unit Redelivery
Exchange sets up the one-to-one relationship having binding.When receiver module 10 receives the state value tried again later and this message
Time, the number of retries that sending module 20 is first arranged according to the message header of this message, select the delay switch that this message is to be beamed back
Delay Exchange.Such as, when the number of retries that the message header in this message is arranged is 1, to be beamed back the prolonging of this message is selected
The late submission Delay Exchange that changes planes is Delay Exchange 1.Then, this message is beamed back the delay message exchange of selection
Machine Delay Exchange, and send the message to postpone delay message team corresponding for message switching unit Delay Exchange
Row Delay Queue.
Further, in the present embodiment, as shown in Figure 4, described sending module 20 includes:
Judging unit 21, for when described state value is for trying again later, it is judged that the weight that the message header of described message is arranged
Whether examination number of times is less than the number of retries threshold value preset;
Select unit 22, for when described number of retries is less than described number of retries threshold value, according to described number of retries
Select the delay switch that described message is to be beamed back.
Further, described sending module 20 is additionally operable to:
When described number of retries is more than described number of retries threshold value, send the message to dead letter message queue.
When again consuming message, message not necessarily can be consumed successfully, it is possible to or consume unsuccessfully, in order to avoid producing
The raw endless loop always consumed some message, in the present embodiment, is previously provided with a number of retries threshold of message
Value, such as, arranging this number of retries threshold value is 16, and this number of retries threshold value can be arranged flexibly according to practical situation,
This is not restricted.When receiver module 10 receives the state value and message that try again later, it is judged that unit 21 judges this message
The number of retries that arranges of message header whether less than the number of retries threshold value preset.Retrying that message header in this message is arranged is secondary
When number is less than number of retries threshold value, namely illustrate that the consumption number of times of this message is also few, now, select unit 22 according to this message
The number of retries that arranges of message header select this message delay switch Delay Exchange to be beamed back, sending module 20 will
This message beams back the delay message switching unit Delay Exchange of selection, and calls delay message switching unit Delay
Exchange sends the message to delayed message queue Delay that this delay message switching unit Delay Exchange is corresponding
Queue.When the number of retries that the message header of message is arranged is more than number of retries threshold value, namely the consumption number of times of this message is described
Too much, now, in order to avoid entering the endless loop that this message carries out consumption process always, sending module 20 is by this message
Send to dead letter message queue Dead Letter Queue.Dead letter message queue Dead Letter Queue can be somebody's turn to do by persistence
Consumption failure, later stage business monitoring can be by disappearing of preserving in extraction dead letter message queue Dead Letter Queue
Expense failure carries out relevant treatment operations.
Further, configurable in Message Queuing server RabbitMQ Server multiple message queue Retry is retried
Queue, each retry message queue Retry Queue have correspondence retry message queue title Retry Queue name.
Further, carry correspondence in message retries message queue title Retry Queue name, when message sends to retrying message
After in switch Redelivery Exchange, retry message queue title Retry Queue according to what this message was carried
Name, send the message to this retry message queue title Retry Queue name corresponding retry message queue Retry
In Queue, obtain and consume this message for customer end RabbitMQ Client afterwards.
The scheme that the present embodiment proposes, the number of retries that the message header in message is arranged is less than the number of retries threshold value preset
Time, sending module 20 sends the message to the delay message switching unit selected, and calls this delay message switching unit and this disappeared
Breath sends to corresponding delayed message queue, this message re-starts consumption and processes, and what the message header in message was arranged retries
When number of times is more than the number of retries threshold value preset, sending module 20 directly sends the message to dead letter message queue, the most right
This message carries out consumption process, it is to avoid enters the endless loop process of unsuccessfully consumption, thus further increases message queue clothes
The Message Processing efficiency of business device.
It should be noted that in this article, term " includes ", " comprising " or its any other variant are intended to non-row
Comprising of his property, so that include that the process of a series of key element, method, article or device not only include those key elements, and
And also include other key elements being not expressly set out, or also include intrinsic for this process, method, article or device
Key element.In the case of there is no more restriction, statement " including ... " key element limited, it is not excluded that including this
The process of key element, method, article or device there is also other identical element.
The invention described above embodiment sequence number, just to describing, does not represent the quality of embodiment.
These are only the preferred embodiments of the present invention, not thereby limit the scope of the claims of the present invention, every utilize this
Equivalent structure or equivalence flow process that bright description and accompanying drawing content are made convert, or are directly or indirectly used in other relevant skills
Art field, is the most in like manner included in the scope of patent protection of the present invention.
Claims (10)
1. a data communications method, it is characterised in that described data communications method comprises the following steps:
Receiving the state value that the message of customer end transmission is corresponding, wherein, described customer end is carrying out business to message
When logical process completes, returning the state value of result, described state value includes successfully, tries again later, unsuccessfully abandons;
When described state value is for trying again later, calls delay message switching unit and send the message to the friendship of described delay message
The delayed message queue of correspondence of changing planes;
After lasting the predetermined time delay that described delayed message queue is corresponding, send the message to retry message queue.
2. data communications method as claimed in claim 1, it is characterised in that the message pair that described reception customer end sends
Before the step of the state value answered, also include:
Send the message to described customer end, for described customer end, described message is carried out at service logic
Reason, and the state value of result is returned by call back function;
Described when described state value is for trying again later, call delay message switching unit and send the message to described delay and disappear
The step of the delayed message queue that breath switch is corresponding includes:
When described state value is for trying again later, the number of retries arranged according to the message header of described message, select described message
Delay message switching unit to be beamed back, and described message is beamed back the described delay message switching unit of selection;
Call described delay message switching unit and send the message to the delay message team that described delay message switching unit is corresponding
Row.
3. data communications method as claimed in claim 2, it is characterised in that described when described state value is for trying again later,
The number of retries that message header according to described message is arranged, the step postponing switch selecting described message to be beamed back includes:
When described state value is for trying again later, it is judged that whether the number of retries that the message header of described message is arranged is less than default
Number of retries threshold value;
When described number of retries is less than described number of retries threshold value, select described message to be beamed back according to described number of retries
Postpone switch.
4. data communications method as claimed in claim 3, it is characterised in that described when described state value is for trying again later,
After judging the step whether number of retries that the message header of described message is arranged is less than the number of retries threshold value preset, also wrap
Include:
When described number of retries is more than described number of retries threshold value, send the message to dead letter message queue.
5. the data communications method as described in any one of claim 1-4, it is characterised in that described lasting described delay message
After the predetermined time delay that queue is corresponding, the step sending the message to retry message queue includes:
After lasting the predetermined time delay that described delayed message queue is corresponding, send the message to described delay message team
What row were corresponding retry message switching unit, and retry described in passing through message switching unit send the message to described in retry message team
Row.
6. a data communication equipment, it is characterised in that described data communication equipment includes:
Receiver module, for receiving the state value that the message of customer end transmission is corresponding, wherein, described customer end is right
Message carries out business logic processing when completing, and returns the state value of result, described state value includes successfully, tries again later,
Unsuccessfully abandon;
Sending module, for when described state value is for trying again later, calls delay message switching unit and sends the message to
The delayed message queue that described delay message switching unit is corresponding;
Processing module, for after lasting the predetermined time delay that described delayed message queue is corresponding, sends the message to
Retry message queue.
7. data communication equipment as claimed in claim 6, it is characterised in that described sending module is additionally operable to:
Send the message to described customer end, for described customer end, described message is carried out at service logic
Reason, and the state value of result is returned by call back function;
And when described state value is for trying again later, the number of retries arranged according to the message header of described message, select described
The delay switch that message is to be beamed back, beams back described message the described delay message switching unit of selection, and calls described delay
Message switching unit sends the message to the delayed message queue that described delay message switching unit is corresponding.
8. data communication equipment as claimed in claim 7, it is characterised in that described sending module includes:
Judging unit, for when described state value is for trying again later, it is judged that the number of retries that the message header of described message is arranged
Whether less than the number of retries threshold value preset;
Select unit, for when described number of retries is less than described number of retries threshold value, selecting institute according to described number of retries
State the delay switch that message is to be beamed back.
9. data communication equipment as claimed in claim 8, it is characterised in that described sending module is additionally operable to:
When described number of retries is more than described number of retries threshold value, send the message to dead letter message queue.
10. the data communication equipment as described in any one of claim 6-9, it is characterised in that described processing module is used for:
After lasting the predetermined time delay that described delayed message queue is corresponding, send the message to described delay message team
What row were corresponding retry message switching unit, and retry described in passing through message switching unit send the message to described in retry message team
Row.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610651790.9A CN106250250A (en) | 2016-08-09 | 2016-08-09 | Data communications method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610651790.9A CN106250250A (en) | 2016-08-09 | 2016-08-09 | Data communications method and device |
Publications (1)
Publication Number | Publication Date |
---|---|
CN106250250A true CN106250250A (en) | 2016-12-21 |
Family
ID=58078753
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201610651790.9A Pending CN106250250A (en) | 2016-08-09 | 2016-08-09 | Data communications method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106250250A (en) |
Cited By (17)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108052398A (en) * | 2017-12-12 | 2018-05-18 | 苏州比可网络科技有限公司 | A kind of feedback method of order processing state and polymerization payment platform |
CN108280150A (en) * | 2018-01-05 | 2018-07-13 | 宝付网络科技(上海)有限公司 | A kind of distribution asynchronous service distribution method and system |
CN108551467A (en) * | 2018-03-15 | 2018-09-18 | 北京雷石天地电子技术有限公司 | A kind of order programme and method |
CN109033289A (en) * | 2018-07-13 | 2018-12-18 | 天津瑞能电气有限公司 | A kind of banking procedure of the high frequency real time data for micro-capacitance sensor |
CN109741179A (en) * | 2018-12-25 | 2019-05-10 | 北京字节跳动网络技术有限公司 | Full gear market data real-time computing technique and device |
CN110138653A (en) * | 2019-05-30 | 2019-08-16 | 北京字节跳动网络技术有限公司 | Message informing method and device |
CN110224922A (en) * | 2019-05-21 | 2019-09-10 | 成都路行通信息技术有限公司 | A kind of asynchronous message based on RabbitMQ retries method, system and system constituting method |
CN110856004A (en) * | 2019-11-05 | 2020-02-28 | 北京字节跳动网络技术有限公司 | Message processing method and device, readable storage medium and electronic equipment |
CN111258776A (en) * | 2020-01-09 | 2020-06-09 | 上海钧正网络科技有限公司 | Disaster recovery method and device for remote service calling |
CN111314422A (en) * | 2020-01-17 | 2020-06-19 | 平安医疗健康管理股份有限公司 | Kafka-based message processing method and system, storage medium and computer equipment |
CN111338810A (en) * | 2018-12-19 | 2020-06-26 | 北京京东尚科信息技术有限公司 | Method and apparatus for storing information |
CN112181737A (en) * | 2020-09-25 | 2021-01-05 | 中国建设银行股份有限公司 | Message processing method and device, electronic equipment and medium |
CN112925642A (en) * | 2021-02-25 | 2021-06-08 | 百果园技术(新加坡)有限公司 | Delayed message processing method, device, equipment and storage medium |
CN114138506A (en) * | 2021-11-08 | 2022-03-04 | 广州华多网络科技有限公司 | Message queue scheduling method and device, equipment, medium and product thereof |
CN114979039A (en) * | 2022-06-21 | 2022-08-30 | 国网电商科技有限公司 | Data processing method and device |
CN116094651A (en) * | 2022-10-31 | 2023-05-09 | 中国电信股份有限公司 | Message retry method, system, electronic device and storage medium |
CN117319320A (en) * | 2023-11-29 | 2023-12-29 | 佛山众陶联供应链服务有限公司 | Retry method and system for message consumption failure of message queue |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1499802A (en) * | 2002-11-11 | 2004-05-26 | ��Ϊ��������˾ | Method for realizing reliable transfering transaction by using mechanism of state machine |
CN101127950A (en) * | 2007-09-04 | 2008-02-20 | 中兴通讯股份有限公司 | A SMS retry processing method, device and its applied SMS center |
CN103200116A (en) * | 2013-04-28 | 2013-07-10 | 成都市欧冠信息技术有限责任公司 | Non-connection-oriented reliable UDP transmission protocol and data transmission method |
CN105677705A (en) * | 2015-12-28 | 2016-06-15 | 湖南蚁坊软件有限公司 | Data processing retry method based on Actor model |
-
2016
- 2016-08-09 CN CN201610651790.9A patent/CN106250250A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1499802A (en) * | 2002-11-11 | 2004-05-26 | ��Ϊ��������˾ | Method for realizing reliable transfering transaction by using mechanism of state machine |
CN101127950A (en) * | 2007-09-04 | 2008-02-20 | 中兴通讯股份有限公司 | A SMS retry processing method, device and its applied SMS center |
CN103200116A (en) * | 2013-04-28 | 2013-07-10 | 成都市欧冠信息技术有限责任公司 | Non-connection-oriented reliable UDP transmission protocol and data transmission method |
CN105677705A (en) * | 2015-12-28 | 2016-06-15 | 湖南蚁坊软件有限公司 | Data processing retry method based on Actor model |
Non-Patent Citations (2)
Title |
---|
XINGKONGWD: "rabbitmq延时消息实现方案(岳小均)", 《HTTPS://MAX.BOOK118.COM/HTML/2015/1002/26532450.SHTM》 * |
笑天居士: "RabbitMQ(四)RabbitMQ死信邮箱", 《HTTPS://BLOG.CSDN.NET/JIAO_FUYOU/ARTICLE/DETAILS/22923935》 * |
Cited By (23)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108052398A (en) * | 2017-12-12 | 2018-05-18 | 苏州比可网络科技有限公司 | A kind of feedback method of order processing state and polymerization payment platform |
CN108280150A (en) * | 2018-01-05 | 2018-07-13 | 宝付网络科技(上海)有限公司 | A kind of distribution asynchronous service distribution method and system |
CN108280150B (en) * | 2018-01-05 | 2023-03-28 | 宝付网络科技(上海)有限公司 | Distributed asynchronous service distribution method and system |
CN108551467A (en) * | 2018-03-15 | 2018-09-18 | 北京雷石天地电子技术有限公司 | A kind of order programme and method |
CN109033289A (en) * | 2018-07-13 | 2018-12-18 | 天津瑞能电气有限公司 | A kind of banking procedure of the high frequency real time data for micro-capacitance sensor |
CN111338810A (en) * | 2018-12-19 | 2020-06-26 | 北京京东尚科信息技术有限公司 | Method and apparatus for storing information |
CN109741179A (en) * | 2018-12-25 | 2019-05-10 | 北京字节跳动网络技术有限公司 | Full gear market data real-time computing technique and device |
CN110224922B (en) * | 2019-05-21 | 2022-04-19 | 成都路行通信息技术有限公司 | Asynchronous message retry method, system and system construction method based on RabbitMQ |
CN110224922A (en) * | 2019-05-21 | 2019-09-10 | 成都路行通信息技术有限公司 | A kind of asynchronous message based on RabbitMQ retries method, system and system constituting method |
CN110138653A (en) * | 2019-05-30 | 2019-08-16 | 北京字节跳动网络技术有限公司 | Message informing method and device |
CN110856004A (en) * | 2019-11-05 | 2020-02-28 | 北京字节跳动网络技术有限公司 | Message processing method and device, readable storage medium and electronic equipment |
CN110856004B (en) * | 2019-11-05 | 2022-02-01 | 北京字节跳动网络技术有限公司 | Message processing method and device, readable storage medium and electronic equipment |
CN111258776A (en) * | 2020-01-09 | 2020-06-09 | 上海钧正网络科技有限公司 | Disaster recovery method and device for remote service calling |
CN111314422A (en) * | 2020-01-17 | 2020-06-19 | 平安医疗健康管理股份有限公司 | Kafka-based message processing method and system, storage medium and computer equipment |
CN112181737A (en) * | 2020-09-25 | 2021-01-05 | 中国建设银行股份有限公司 | Message processing method and device, electronic equipment and medium |
CN112925642A (en) * | 2021-02-25 | 2021-06-08 | 百果园技术(新加坡)有限公司 | Delayed message processing method, device, equipment and storage medium |
CN114138506A (en) * | 2021-11-08 | 2022-03-04 | 广州华多网络科技有限公司 | Message queue scheduling method and device, equipment, medium and product thereof |
CN114138506B (en) * | 2021-11-08 | 2024-06-21 | 广州华多网络科技有限公司 | Message queue scheduling method and device, equipment, medium and product thereof |
CN114979039A (en) * | 2022-06-21 | 2022-08-30 | 国网电商科技有限公司 | Data processing method and device |
CN116094651A (en) * | 2022-10-31 | 2023-05-09 | 中国电信股份有限公司 | Message retry method, system, electronic device and storage medium |
CN116094651B (en) * | 2022-10-31 | 2024-05-14 | 中国电信股份有限公司 | Message retry method, system, electronic device and storage medium |
CN117319320A (en) * | 2023-11-29 | 2023-12-29 | 佛山众陶联供应链服务有限公司 | Retry method and system for message consumption failure of message queue |
CN117319320B (en) * | 2023-11-29 | 2024-02-13 | 佛山众陶联供应链服务有限公司 | Retry method and system for message consumption failure of message queue |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106250250A (en) | Data communications method and device | |
CN102469033B (en) | Message subscription system and message sending method | |
CN103220206B (en) | Message sending method and device and message receiving method and device | |
CN106657349A (en) | Message subscription processing device, system and method | |
CA2578602A1 (en) | Rule based data collection and management in a wireless communications network | |
CN102387265A (en) | Calling connection method and calling platform | |
CN103677988B (en) | The multi-process means of communication and system for software systems | |
CN101174955A (en) | Sharing contents transmission mode and system, contents source terminal and contents receiving end | |
CN107734076A (en) | Information push method, device and storage medium | |
CN106250249A (en) | The control method of message queue and device | |
CN105677451A (en) | Load balancing method and equipment used for multiple processes | |
CN111385269A (en) | Data transmission method and device | |
CN105242975A (en) | Message transmission method and message middleware | |
CN101288238B (en) | Device and method for expressing status of terminal using character | |
CN102264049A (en) | Cell message system and processing method thereof | |
CN104702647A (en) | Information request method and information request system | |
CN106453582A (en) | Asynchronous message pushing method and system | |
CN101127950B (en) | A SMS retry processing method, device and SMS center applying the same | |
CN101753561B (en) | Business cluster processing method and cluster system | |
CN113992609B (en) | Method and system for processing multilink service data disorder | |
CN108243397B (en) | Short message sending method and short message gateway equipment | |
CN109067864A (en) | Notification message method for pushing, device and electronic equipment | |
CN112181672B (en) | Block chain data processing method, block chain system and computer storage medium | |
CN102761527B (en) | The access method of serving in cluster and system | |
CN101303658B (en) | Communicating method and device based on front/background mission |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
TA01 | Transfer of patent application right |
Effective date of registration: 20171207 Address after: 510000 Guangzhou City, Guangzhou, Guangdong, Fangcun Avenue, one of the 314 self compiled Applicant after: Guangzhou Pinwei Software Co., Ltd. Address before: Liwan District Fangcun Huahai street Guangzhou city Guangdong province 510000 No. 20 self 1-5 building (only for office use) Applicant before: Guangzhou VIPSHOP Information and Technology Co., Ltd. |
|
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20161221 |