A kind of dissemination method of persistent message and system
Technical field
The present invention relates to field of data communication is and in particular to a kind of dissemination method of persistent message and system.
Background technology
In the message-oriented middleware working mechanism of data switching center, a data exchange server is generally had to connect multiple stage
Data exchange client, carries out message by data exchange server between multiple stage data exchange client and transmits data friendship
Change.Decoupling, sender of the message and message are realized by data exchange server in this mechanism message sending end and message sink end
Recipient is without also can carrying out message transmission online simultaneously.
Data exchange server, when receiving the real-time messages of message sending end, real-time messages is stored in receiving terminal corresponding
In message queue, then forward messages to message sink end.In order to ensure the reliability of message transmission, data exchange server meeting
Message is saved in non-volatile memory device, when the emergency case such as power down, system exception collapse occur, data exchange service
Device restarts and can load the message being persisted to non-volatile memory device, forwards it to corresponding message sink end.
Message is read in internal memory from non-volatile memory device and then is stored in the process of message queue, referred to as persistent message is issued.
Data exchange server generally supports multiplexing technique, and so-called multiplexing refers to transmitting terminal in pocket transmission news
When (message is issued multiple receiving terminals or broadcast transmission), only send a piece of news to data exchange server, by data exchange
Server forwards messages to multiple message sink ends respectively according to message route results, this approach reduces transmitting terminal to number
The size of message sending according to swap server, saves the network bandwidth, improves the efficiency of mass-sending.As shown in Figure 1, transmitting terminal sends one
Pocket transmission news, only need to send a piece of news to data exchange server, and server forwards that message to multiple receiving terminals (figure again
1 show three receiving terminals).Multiplexing technique makes data exchange server need the message count forwarding to message sink end
Amount is far longer than the message number receiving from message sending end, and its result is the speed of message forwarding substantially than the speed of message sink
Degree is a lot of slowly.Message in message queue cannot forward in time, ultimately result in message queue and be occupied full, and part messages are only non-
Preserve in volatile storage devices, be not stored in message queue.After the message in message queue is forwarded, can be discharged it
The memory space taking, at this moment needs again the message of persistence to be read in internal memory, then publishes in message queue
Row forwards.
During persistent message is issued, the message receiving apparatus of usual data exchange server, also in work, are gone back
Receiving the message that message sending end sends, period there is also the situation that queue is done.Fig. 2 issues persistence for prior art and disappears
The operation principle schematic diagram of breath, in prior art, is busy feelings if there is message queue in persistent message issuing process
Condition, it is often necessary to sleep waits one time specified, goes after sleep time-out to obtain the state of message queue again;If queue is
Hurry and continue to sleep wait, after time-out, obtain message queue state again, so repeatedly, until message queue then proceeded to for the free time
Issue, as shown in step 201-208.As shown in Fig. 2 step 204, sleep waiting mechanism just must can go inquiry to disappear when time-out
Breath quene state, if be set as the length of one's sleep 60 seconds it is necessary to wait 60 seconds time-out just to go the state of query messages queue.This
By repeatedly obtaining whether message queue is that there are the following problems for method that is idle and then issuing:Even if message queue is idle
Also this is needed to wait time-out just to go to obtain the idle condition of message queue, ability initiation message release process, during time-out of such as sleeping
Between be set to 60 seconds, the message in message queue after having waited 5 seconds is removed, also need again wait just go query messages queue within 55 seconds
State, this maximized cannot improve the real-time that message forwards.Although the waiting time can be shortened by, increase inquiry
Frequency is tried one's best and is improved the real-time that message forwards, but the waiting time is too short, if message queue is in busy condition for a long time, frequently
The state of numerous query messages queue has no meaning, can affect performance on the contrary.Therefore, prior art sends if there is a large amount of message
When (including real-time messages and persistent message), issue persistent message efficiency is low, and message forwards poor real.
Content of the invention
For the problem in the presence of prior art, in order to solve prior art cycle when issuing a large amount of persistent message
Property the efficiency that waits the state of query messages queue and cause low, message forwards the problem of poor real, and the purpose of the present invention is
A kind of dissemination method of persistent message and system, the method and system is provided to introduce in persistent message issuing process
Treat, informing mechanism, persistent message issuing process is triggered by event it is ensured that data exchange server receives, forwards a large amount of
It is ensured that message efficient, reliable transmission in the case of message, also improve the real-time of persistent message transmission simultaneously.
A kind of dissemination method of persistent message, comprises the following steps:
(1) message receiving apparatus receive the real-time messages that message sending end is sent to data exchange server, and will be described
Real-time messages are persisted to non-volatile memory device;
(2) persistent message reading device reads the persistent message being persisted on non-volatile memory device;
(3) described persistent message is stored in message queue persistent message distributing device;Persistent message is being deposited
Before entering message queue, judge whether message queue is busy, if message queue is busy, persistent message distributing device will be temporary
Constantly running simultaneously enters waiting state, the idle notice that the queue that waits for the arrival of news sends;
(4), after Dispatch Unit extracts the message in message queue, message sink end, message queue are forwarded messages to
Notification event will be sent to persistent message distributing device, and notify described persistent message distributing device to terminate waiting;
(5) persistent message distributing device continues executing with from next sentence waiting sentence, continues to send out toward message queue
Cloth message.
Further, each message sink end corresponds to unique persistent message distributing device, for described message sink
Corresponding message queue is held to issue persistent message.
Further, each message sink end corresponds to unique message queue, for depositing the real-time of message sending end transmission
Message and the persistent message of persistent message distributing device issue.
Further, in step (3), described persistent message distributing device operation suspension when entering waiting state, persistently
Change news release device and will wait until the idle notice receiving message queue always, continue to issue persistent message.
Further, in step (3), Dispatch Unit extracting message and after discharging memory headroom from message queue,
Message queue immediately to persistent message distributing device send idle notify, notify persistent message distributing device can continue to
Message queue issues persistent message.
Further, in step (3), Dispatch Unit is before extracting message from message queue by lockout message team
Row, will release the locking to message queue after extracting message from message queue.
Present invention also offers a kind of delivery system of persistent message, including data exchange server, message sending end,
Message sink end, described data exchange server includes following device:
Message receiving apparatus:It is sent to the real-time messages of data exchange server for receiving message sending end, and by institute
State real-time messages and be persisted to non-volatile memory device;
Persistent message reading device:For reading the persistent message being persisted on non-volatile memory device;
Persistent message distributing device:Persistent message for reading persistent message reading device is published to message
Queue, before persistent message is stored in message queue, judges whether message queue is busy, if message queue is busy, holds
Longization news release device will operation suspension enter waiting state, the idle notice that the queue that waits for the arrival of news sends;
Message queue:There are real-time messages to be forwarded and persistent message for depositing message sink end in internal memory, disappear
Breath can send idle notice to persistent message distributing device when being extracted;
Dispatch Unit:For extracting message from message queue and forwarding messages to message sink end.
Further, this system also includes message routing apparatus, for determining that message receiving apparatus receive according to route setting
Real-time messages one or more receiving terminals, and described real-time messages are stored in the idle message queue in corresponding message sink end
In.
Further, the corresponding unique persistent message distributing device in each message sink end and unique message queue.
Effect of the invention is that:Method and system of the present invention introduce event in persistent message issuing process
Trigger mechanism, the message in message queue is extracted after discharging memory space, and message queue is issued to persistent message immediately
Device sends idle notice, notifies persistent message distributing device can continue to issue persistent message to message queue.Pass through
Using the method for the present invention it is ensured that data exchange server a large amount of receive, forward message in the case of, persistent message and reality
When message efficient, the reliable real-time transmitted, also improve persistent message transmission simultaneously.
Brief description
Fig. 1 is the operation principle schematic diagram of multiplexing technique;
Fig. 2 issues the operation principle schematic diagram of persistent message for prior art;
Fig. 3 is overall work schematic diagram of the present invention;
Fig. 4 is a kind of system construction drawing of the delivery system specific embodiment of persistent message of the present invention;
Fig. 5 is a kind of flow chart of the dissemination method specific embodiment of persistent message of the present invention.
Specific embodiment
The invention will be further described with reference to the accompanying drawings and detailed description.
A kind of delivery system of persistent message described in the invention, as shown in figure 3, it includes:Data exchange service
Device, message exchange client, described message exchange client includes message sending end, message sink end.
Fig. 4 is according to a kind of schematic device of the embodiment of the delivery system of persistent message of the present invention.Its
Middle data exchange server 41 is the core of the present invention, and message sending end 42 and message sink end 43 are used for describing this
Bright, described data exchange server 41 includes following device:
Message receiving apparatus 411, this device is used for receiving the reality that message sending end 42 is sent to data exchange server 41
When message, and described real-time messages are persisted to non-volatile memory device.
Message routing apparatus 412, this device is used for the one or more of the real-time messages according to route setting determination reception
Message sink end, and described real-time messages are stored in the idle message queue in corresponding message sink end.
Persistent message reading device 413, for reading the persistent message being persisted on non-volatile memory device.
Persistent message distributing device 414, the persistent message for reading persistent message reading device is published to
The message queue at corresponding message sink end, before persistent message is stored in the message queue at corresponding message sink end, judges
Whether message queue is busy, if message queue is busy, persistent message distributing device will operation suspension enter wait shape
State, the idle notice that the queue that waits for the arrival of news sends.
Message queue 415, has real-time messages to be forwarded and persistent message for depositing message sink end in internal memory,
Message can send idle notice to persistent message distributing device when being extracted.
Dispatch Unit 416, for extracting message from message queue 415 and forwarding messages to message sink end 43.
In the present embodiment, each message sink end corresponds to unique persistent message distributing device and unique message team
Row.
Fig. 5 shows according to a kind of flow process of an embodiment of the dissemination method of persistent message of the present invention
Figure, comprises the following steps:
S501, from non-volatile memory device load persistence messaging list;
If the described messaging list that S502 obtains is sky, represent the message not having persistence, then enter step S510;
Otherwise enter step S503;
First persistent message in S503, the negated volatile storage devices of persistent message readout means reads;
S504, persistent message distributing device judge whether message queue is busy, if message queue is busy, execute step
Rapid S505;Otherwise execution step S507;
S505, persistent message distributing device operation suspension simultaneously enter waiting state, the free time that the queue that waits for the arrival of news sends
Notify;
The free time that S506, persistent message distributing device receive message queue notifies the implementation procedure of follow-up onward sequence,
Enter step S507;
Then persistent message is put into described message queue by S507, persistent message distributing device lockout message queue
In, release the locking to message queue after the completion of putting into;After lockout message queue, forbid this message queue of other routine accesses;
Whether S508, persistent message distributing device judge to have on non-volatile memory device what next did not issued to disappear
Breath, if there are the message do not issued then execution step S509;Otherwise execution step S510;
Next persistent message in S509, the negated volatile storage devices of persistent message readout means reads;Then
Enter step S504;
S510, persistent message distributing device complete this news release, out of service.
In the present embodiment, each message sink end corresponds to unique persistent message distributing device, for described message
Receiving terminal issues persistent message.Each message sink end corresponds to unique message queue, sends out for depositing message in internal memory
Real-time messages and the persistent message of persistent message distributing device issue that sending end sends.
A kind of dissemination method of persistent message of the present invention and system are not limited to described in specific embodiment
Embodiment, those skilled in the art's technology according to the present invention scheme draws other embodiments, also belongs to the present invention
Technological innovation scope.