A kind of dissemination method of persistence message and system
Technical field
The present invention relates to the data communication field, be specifically related to a kind of dissemination method and system of persistence message.
Background technology
In the message-oriented middleware working mechanism of data switching center, usually there is a number of units to connect many number of units according to the exchange client according to swap server, many number of units are according between the exchange client, by the data exchange service device, carrying out transmission of messages and exchanges data.This machine-processed message sending end and message sink end are realized decoupling zero by the data exchange service device, and sender of the message and message recipient need not also can carry out transmission of messages online simultaneously.
The data exchange service device, when receiving the real-time messages of message sending end, deposits real-time messages in the message queue that receiving terminal is corresponding in, then message is transmitted to the message sink end.In order to guarantee the reliability of transmission of messages, the data exchange service device can be kept at non-volatile memory device by message, when the emergency case such as power down, system exception collapse occurring, data exchange service is thought highly of new startup can load the message that is persisted to non-volatile memory device, and it is transmitted to corresponding message sink end.Message is read in to the process that then internal memory deposits message queue in from non-volatile memory device, be called the persistence data publish.
The data exchange service device is generally supported multiplexing technique, what is called is multiplexed refers to that transmitting terminal is when pocket transmission news (issuing a plurality of receiving terminals or broadcast transmission by message), only to the data exchange service device, send a piece of news, respectively message is transmitted to a plurality of message sink ends by the data exchange service device according to the message route results, this mode has reduced the size of message that transmitting terminal sends to the data exchange service device, save the network bandwidth, improve the efficiency of mass-sending.As shown in Figure 1, transmitting terminal sends a pocket transmission news, only need send a piece of news to the data exchange service device, and server is transmitted to this message a plurality of receiving terminals (Figure 1 shows that three receiving terminals) again.The message number that multiplexing technique makes the data exchange service device to forward to the message sink end is far longer than the message number received from message sending end, and the speed that consequently message forwards is obviously a lot of slowly than the speed of message sink.Message in message queue can not get timely forwarding, finally causes message queue to be occupied full, and part message is only preserved in non-volatile memory device, is not stored in message queue.After message in message queue is forwarded, can discharge the memory space that it takies, at this moment need again the message of persistence to be read in to internal memory, then publish in message queue and forwarded.
In the process of persistence data publish, usually the message receiving apparatus of data exchange service device is also in work, the message also sent at the receipt message transmitting terminal, during also there will be the busy situation of queue.The operation principle schematic diagram that Fig. 2 is prior art issue persistence message, in prior art, be busy situation if there is message queue in persistence data publish process, usually must sleep wait for the time of one section appointment, sleep after overtime and remove again to obtain the state of message queue; If queue just continues sleep and waits for for busy, obtain again the message queue state after overtime, so repeatedly, until message queue is then to continue issue the free time, as shown in step 201-208.As shown in Fig. 2 step 204, the sleep waiting mechanism must be waited until and overtimely just can remove the query messages quene state, if be set as 60 seconds the length of one's sleep, must wait for 60 seconds overtime states that just go the query messages queue.Whether this be that there are the following problems for the idle method of then issuing by repeatedly obtaining message queue: even message queue is idle, also need this wait timeout just to go to obtain the idle condition of message queue, ability initiation message release process, as the time-out time of sleeping is made as 60 seconds, message after having waited for 5 seconds in message queue is removed, also need to wait again the state that just goes the query messages queue in 55 seconds, this just can not be maximized the real-time that forwards of raising message.Although can be by shortening the stand-by period, the frequency that increases inquiry improves the real-time that message forwards as far as possible, the stand-by period is too short, if message queue for a long time in busy condition, the state of frequent query messages queue is also meaningless, can affect performance on the contrary.Therefore, if when prior art exists a large amount of message to send (comprising real-time messages and persistence message), issue persistence message efficiency is low, and it is poor that message forwards real-time.
Summary of the invention
For existing problem in prior art, periodically wait for the state of query messages queue during a large amount of persistence message and the efficiency that causes is low in order to solve prior art in issue, message forwards the poor problem of real-time, the dissemination method and the system that the purpose of this invention is to provide a kind of persistence message, the method and system have been introduced wait in persistence data publish process, informing mechanism, by Event triggered persistence data publish process, guarantee that the data exchange service device is in a large amount of receptions, in the situation of forwarding messages, assurance message is efficient, transmission reliably, also improved the real-time that persistence message transmits simultaneously.
A kind of dissemination method of persistence message comprises the following steps:
(1) message receiving apparatus receipt message transmitting terminal sends to the real-time messages of data exchange service device, and described real-time messages is persisted to non-volatile memory device;
(2) persistence message reading device reads the persistence message be persisted on non-volatile memory device;
(3) persistence data publish device deposits described persistence message in message queue in; Before depositing persistence message in message queue, judge whether message queue is busy, if message queue for busy, persistence data publish device will operation suspension and is entered wait state, the free time notice that the queue that waits for the arrival of news sends;
(4) after Dispatch Unit extracts the message in message queue, message is transmitted to the message sink end, message queue will send notification event to persistence data publish device, notify described persistence data publish device to stop waiting for;
(5) persistence data publish device continues to carry out from next statement of wait statement, continues to give out information toward message queue.
Further, the persistence data publish device that each message sink end is corresponding unique, for the message queue issue persistence message corresponding to described message sink end.
Further, the message queue that each message sink end is corresponding unique, for depositing real-time messages that message sending end sends and the persistence message of persistence data publish device issue.
Further, in step (3), described persistence data publish device operation suspension while entering wait state, persistence data publish device will be waited for always, until receive the free time notice of message queue, continues issue persistence message.
Further, in step (3), Dispatch Unit is extracting message and discharging memory headroom from message queue, message queue sends idle notice to persistence data publish device immediately, and notice persistence data publish device can continue to message queue issue persistence message.
Further, in step (3), Dispatch Unit by the lockout message queue, will removed the locking to message queue before from message queue, extracting message after message queue extracts message.
The present invention also provides a kind of delivery system of persistence message, comprises data exchange service device, message sending end, message sink end, and described data exchange service device comprises with lower device:
Message receiving apparatus: send to the real-time messages of data exchange service device for the receipt message transmitting terminal, and described real-time messages is persisted to non-volatile memory device;
Persistence message reading device: for reading the persistence message be persisted on non-volatile memory device;
Persistence data publish device: for persistence data publish that persistence message reading device is read to message queue, before depositing persistence message in message queue, judge whether message queue is busy, if message queue is for busy, persistence data publish device will operation suspension and is entered wait state, the free time notice that the queue that waits for the arrival of news sends;
Message queue: the real-time messages and the persistence message that remain forwarding for deposit the message sink end at internal memory, message can send idle notice to persistence data publish device when being extracted;
Dispatch Unit: for from message queue, extracting message and message is transmitted to the message sink end.
Further, this system also comprises the message route device, for one or more receiving terminals of the real-time messages of determining that message receiving apparatus receives are set according to route, and described real-time messages is deposited in the message queue of corresponding message sink end free time.
Further, persistence data publish device corresponding to each message sink end and unique message queue.
Effect of the present invention is: method and system of the present invention are introduced event trigger mechanism in persistence data publish process, after message in message queue is extracted and discharges memory space, message queue sends idle notice to persistence data publish device immediately, and notice persistence data publish device can continue to message queue issue persistence message.The method of the application of the invention, guarantee the data exchange service device in the situation that receive in a large number, forwarding messages, persistence message and real-time messages are efficient, transmission reliably, have also improved the real-time that persistence message transmits simultaneously.
The accompanying drawing explanation
The operation principle schematic diagram that Fig. 1 is multiplexing technique;
The operation principle schematic diagram that Fig. 2 is prior art issue persistence message;
Fig. 3 is overall work schematic diagram of the present invention;
The system construction drawing of the delivery system embodiment that Fig. 4 is a kind of persistence message of the present invention;
The flow chart of the dissemination method embodiment that Fig. 5 is a kind of persistence message of the present invention.
Embodiment
Below in conjunction with the drawings and specific embodiments, the invention will be further described.
The delivery system of a kind of persistence message described in the invention, as shown in Figure 3, it comprises: data exchange service device, message client, described message client comprises message sending end, message sink end.
Fig. 4 is the device schematic diagram according to the embodiment of the delivery system of a kind of persistence message of the present invention.Wherein data exchange service device 41 is cores of the present invention, and message sending end 42 and message sink end 43 are for describing the present invention, and described data exchange service device 41 comprises with lower device:
Message receiving apparatus 411, this device sends to the real-time messages of data exchange service device 41 for receipt message transmitting terminal 42, and described real-time messages is persisted to non-volatile memory device.
Message route device 412, this device is used for, according to route, one or more message sink ends of determining the real-time messages received are set, and described real-time messages is deposited in the message queue of corresponding message sink end free time.
Persistence message reading device 413, for reading the persistence message be persisted on non-volatile memory device.
Persistence data publish device 414, arrive the message queue of corresponding message sink end for the persistence data publish that persistence message reading device is read, before depositing persistence message the message queue of corresponding message sink end in, judge whether message queue is busy, if message queue is for busy, persistence data publish device will operation suspension and is entered wait state, the free time notice that the queue that waits for the arrival of news sends.
Message queue 415, the real-time messages and the persistence message that remain forwarding for deposit the message sink end at internal memory, message can send idle notice to persistence data publish device when being extracted.
Dispatch Unit 416, for extracting message and message be transmitted to message sink end 43 from message queue 415.
In the present embodiment, the persistence data publish device that each message sink end is corresponding unique and unique message queue.
Fig. 5 shows the flow chart according to an embodiment of the dissemination method of a kind of persistence message of the present invention, comprises the following steps:
S501, from non-volatile memory device, load the messaging list of persistence;
If the described messaging list that S502 obtains, for empty, means not have the message of persistence, enter step S510; Otherwise enter step S503;
S503, persistence message reading device read article one persistence message on non-volatile memory device;
S504, persistence data publish device judge whether message queue is busy, if message queue is for hurrying performing step S505; Otherwise execution step S507;
S505, persistence data publish device operation suspension also enter wait state, the free time notice that the queue that waits for the arrival of news sends;
S506, persistence data publish device receive the implementation of the rear continuation program of free time notice of message queue, enter step S507;
S507, the queue of persistence data publish device lockout message, then put into described message queue by persistence message, put into the locking of rear releasing to message queue; After the lockout message queue, forbid this message queue of other routine accesses;
S508, persistence data publish device judge the message that whether has next not issue on non-volatile memory device, if the message of not issue is arranged perform step S509; Otherwise execution step S510;
S509, persistence message reading device read next the persistence message on non-volatile memory device; Then enter step S504;
S510, persistence data publish device complete this data publish, out of service.
In the present embodiment, the persistence data publish device that each message sink end is corresponding unique, for issuing persistence message to described message sink end.The message queue that each message sink end is corresponding unique, for depositing real-time messages that message sending end sends and the persistence message of persistence data publish device issue at internal memory.
The dissemination method of a kind of persistence message of the present invention and system are not limited to the embodiment described in embodiment, those skilled in the art's technical scheme according to the present invention draws other execution mode, belongs to equally technological innovation scope of the present invention.