CN109450778A - A kind of message delay delivering method, device and equipment - Google Patents

A kind of message delay delivering method, device and equipment Download PDF

Info

Publication number
CN109450778A
CN109450778A CN201811626539.2A CN201811626539A CN109450778A CN 109450778 A CN109450778 A CN 109450778A CN 201811626539 A CN201811626539 A CN 201811626539A CN 109450778 A CN109450778 A CN 109450778A
Authority
CN
China
Prior art keywords
message
time
delivery
file
index information
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
Application number
CN201811626539.2A
Other languages
Chinese (zh)
Inventor
冯浩
虞开元
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing IQIYI Science and Technology Co Ltd
Original Assignee
Beijing IQIYI Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing IQIYI Science and Technology Co Ltd filed Critical Beijing IQIYI Science and Technology Co Ltd
Priority to CN201811626539.2A priority Critical patent/CN109450778A/en
Publication of CN109450778A publication Critical patent/CN109450778A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L51/00User-to-user messaging in packet-switching networks, transmitted according to store-and-forward or real-time protocols, e.g. e-mail
    • H04L51/21Monitoring or handling of messages
    • H04L51/214Monitoring or handling of messages using selective forwarding
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/50Queue scheduling
    • H04L47/56Queue scheduling implementing delay-aware scheduling
    • H04L47/568Calendar queues or timing rings
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • H04L67/562Brokering proxy services
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W4/00Services specially adapted for wireless communication networks; Facilities therefor
    • H04W4/12Messaging; Mailboxes; Announcements
    • H04W4/14Short messaging services, e.g. short message services [SMS] or unstructured supplementary service data [USSD]

Abstract

The embodiment of the invention provides a kind of message delay delivering method, device and equipment, wherein this method comprises: obtaining each message for reaching target time of delivery and obtaining each index information of each message;Each message and each index information are pre-loaded into the memory at messaging service end;Target time of delivery includes any point-in-time;For each message, send the message to the Commit Log at messaging service end, and the corresponding index information of the message is sent to the consumption queue at information consumption end, so that information consumption end obtains the message according to index information from Commit Log, and consumes to message.It so, it is possible the application range of extension delay delivery process.

Description

A kind of message delay delivering method, device and equipment
Technical field
The present invention relates to Internet technical fields, more particularly to a kind of message delay delivering method, device and equipment.
Background technique
Message system is because of its traditional functional characteristics: the asynchronous decoupling called between system, the complexity for lowering system, flow Peak load shifting, stretch convenient for business resiliency, be easily achieved final consistency system, avoid distributed transaction to the shadow of performance It rings, support P2P (point-to-point calling) and pub/sub (publish/subscribe) mode, reduction RPC (Remote Procedure Call Protocol, remote procedure call protocol) it is multiple calling etc..It is widely used at present in Internet enterprises, it is all kinds of Operation system has its figure.In addition with the rapid growth of business, enterprises need the synchronous transfer of mass data, stream Formula the application such as calculates and requires highly stable efficient transmission channel and give to support, message system is wherein acting as important angle Color.
And in the business of exploitation, certain business scenarios need message to regularly send or be delayed transmission, and the short message such as Fetion is fixed When send demand.At this time, it is necessary to which message system carries out delay delivery to message.
In existing message delay delivery process, the delay dimension of limited fixation is only supported, can not accurately meet has The latency requirement except a constant time lag dimension is limited, so that application range is limited.
Summary of the invention
The embodiment of the present invention is designed to provide a kind of message delay delivering method, device and equipment, to extend delay The application range of delivery process.Specific technical solution is as follows:
In a first aspect, being applied to messaging service end, packet the embodiment of the invention provides a kind of message delay delivering method It includes:
It obtains each message for reaching target time of delivery and obtains each index information of each message;Each message And each index information is pre-loaded into the memory at the messaging service end;When the target time of delivery includes any Between point;
For each message, the Commit Log at the messaging service end is sent the message to, and the message is corresponding The index information be sent to the consumption queue at information consumption end so that the information consumption end according to the index information from The message is obtained in the Commit Log, and the message is consumed.
Optionally, each message for reaching target time of delivery and each index for obtaining each message are obtained described Before information, the method also includes:
For each message, when receiving the message of message manufacturing side transmission, determine that the target of the message is thrown Pass the time;
Determine the time of delivery section that the target time of delivery is located at;
The message is saved into Block file corresponding to the time of delivery section, and by the corresponding index of the message Information preservation is to the Block file.
Optionally, the message is saved into Block file corresponding to the time of delivery section described, and by the message pair The index information answered is saved to the Block file, the method also includes:
When being put at the beginning of reaching the time of delivery section, by the corresponding Block text of the time of delivery section The each message saved in part is loaded onto the memory at the messaging service end;And it is the time of delivery section is corresponding described Each index information of each message saved in Block file is loaded onto the memory at the messaging service end.
It is optionally, described that the message is saved into Block file corresponding to the time of delivery section, comprising:
The message is saved to message file, the message file is the corresponding Block text of the time of delivery section The subfile of part;
The each message that will be saved in the corresponding Block file of the time of delivery section is loaded onto described disappear Cease the memory of server-side, comprising:
The message file including each information is obtained from the Block file;
The message file is loaded onto the memory at the messaging service end;
It is described to save the corresponding index information of the message to the Block file, comprising:
The corresponding index information of the message is saved to index file, the index file is the time of delivery section The subfile of the corresponding Block file;
Each index by each message saved in the corresponding Block file of the time of delivery section is believed Breath, is loaded onto the memory at the messaging service end, comprising:
The index file including each index information is obtained from the Block file;
The index file is loaded onto the memory at the messaging service end.
Optionally, described by each of each message saved in the corresponding Block file of the time of delivery section A index information is loaded onto after the memory at the messaging service end, the method also includes:
The time of delivery section is divided, the corresponding each time of delivery of the time of delivery section is obtained;
For each time of delivery, the corresponding index information of the time of delivery is saved into chained list corresponding to the time of delivery Slot position;
The each index information for obtaining each message, comprising:
For each message, the corresponding target chained list slot position of the target time of delivery of the message is determined;The target is delivered Time includes in the corresponding each time of delivery of the time of delivery section;
The index information of the message is obtained from the target chained list slot position.
Second aspect, the embodiment of the invention provides a kind of message delay delivery apparatus, are applied to messaging service end, packet It includes:
Module is obtained, for obtaining each message for reaching target time of delivery and each index for obtaining each message Information;Each message and each index information are pre-loaded into the memory at the messaging service end;The target is delivered Time includes any point-in-time;
Sending module, for sending the message to the Commit Log at the messaging service end for each message, and The corresponding index information of the message is sent to the consumption queue at information consumption end, so that the information consumption end is according to institute It states index information and obtains the message from the Commit Log, and the message is consumed.
Optionally, described device further include:
First determining module, for being directed to each message, when receiving the message of message manufacturing side transmission, determining should The target time of delivery of message;
Second determining module, the time of delivery section being located at for determining the target time of delivery;
First preserving module for the message to be saved Block file corresponding to the time of delivery section, and this is disappeared The corresponding index information is ceased to save to the Block file.
Optionally, described device further include:
Loading module, it is when for being put at the beginning of reaching the time of delivery section, the time of delivery section is corresponding The Block file in each message for saving, be loaded onto the memory at the messaging service end;And by the time of delivery section Each index information of each message saved in the corresponding Block file, is loaded onto the memory at the messaging service end.
Optionally, first preserving module, specifically for saving the message to message file, the message file is The subfile of the corresponding Block file of the time of delivery section;
The loading module, specifically for obtaining the message file including each information from the Block file; The message file is loaded onto the memory at the messaging service end;
First preserving module, specifically for saving the corresponding index information of the message to index file, institute State the subfile that index file is the corresponding Block file of the time of delivery section;
The loading module, specifically for obtaining the index including each index information from the Block file File;The index file is loaded onto the memory at the messaging service end.
Optionally, described device further include:
Division module obtains the corresponding each throwing of the time of delivery section for dividing to the time of delivery section Pass the time;
Second preserving module saves the corresponding index information of the time of delivery to this for being directed to each time of delivery The corresponding chained list slot position of time of delivery;
The acquisition module is specifically used for being directed to each message, determines the corresponding target of target time of delivery of the message Chained list slot position;The target time of delivery includes in the corresponding each time of delivery of the time of delivery section;From the target The index information of the message is obtained in chained list slot position.
The third aspect, the embodiment of the invention provides a kind of message delay delivery device, including processor, communication interface, Memory and communication bus, wherein the processor, the communication interface, the memory are completed by the communication bus Mutual communication;
The memory, for storing computer program;
The processor when for executing the program stored on the memory, is realized described in above-mentioned first aspect Method and step.
At the another aspect that the present invention is implemented, a kind of computer readable storage medium is additionally provided, it is described computer-readable Instruction is stored in storage medium, when run on a computer, so that computer executes side described in above-mentioned first aspect Method step.
At the another aspect that the present invention is implemented, the embodiment of the invention also provides a kind of, and the computer program comprising instruction is produced Product, when run on a computer, so that computer executes method and step described in above-mentioned first aspect.
Message delay delivering method, device and equipment provided in an embodiment of the present invention, it is available reach target deliver when Between each message and obtain each index information of each message, each message and each index information are pre-loaded Into the memory at messaging service end;Target time of delivery includes any point-in-time;For each message, sends the message to and disappear The Commit Log of server-side is ceased, and the corresponding index information of the message is sent to the consumption queue at information consumption end, so that Information consumption end obtains the message according to index information from Commit Log, and consumes to message.The embodiment of the present invention In, the delay that the message that time of delivery is any point-in-time may be implemented is delivered, and the delay that can satisfy any delay dimension needs It asks, the application range of extension delay delivery process, and improves the flexibility that message delay is delivered.Certainly, implement of the invention appoint One product or method must be not necessarily required to reach all the above advantage simultaneously.
Detailed description of the invention
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below There is attached drawing needed in technical description to be briefly described.
Fig. 1 is the flow chart of message delay delivering method provided in an embodiment of the present invention;
Fig. 2 is the flow chart that message is saved in the embodiment of the present invention;
Fig. 3 is the flow chart handled in the embodiment of the present invention index information;
Fig. 4 is the flow chart that index information is obtained in the embodiment of the present invention;
Fig. 5 is the flow diagram of specific embodiment provided in an embodiment of the present invention;
Fig. 6 is the structural schematic diagram of message delay delivery apparatus provided in an embodiment of the present invention;
Fig. 7 is the structural schematic diagram of message delay delivery device provided in an embodiment of the present invention.
Specific embodiment
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention is described.
In the business of exploitation, certain business scenarios need message to regularly send or be delayed transmission, such as the short message timing of Fetion Transmission demand.At this time, it is necessary to which message system carries out delay delivery to message.
In existing message delay delivery process, the delay dimension of limited fixation is only supported.So that apply Range is limited.In addition, messaging service end receives the message that the message manufacturing side is sent in existing message delay delivery process, and According to message to delay time, message is saved into corresponding message queue, and message queue is stored in messaging service In the Commit Log at end.
Because that storage message queue is the Commit Log for storing message body in messaging service end, if Commit Log By excessive occupancy, the performance at messaging service end will affect.Therefore, in the prior art, in order to avoid to message server-side shadow Sound is excessive, usually establishes limited message queue, that is, distinguishes limited message dimension.The corresponding message dimension of one message The corresponding time of delivery of degree, i.e. message queue, so doing, it is possible to cause the message different to delay time, by according to Same time of delivery is delivered.So will affect the accuracy of delivery, can not accurately meet limited constant time lag dimension it Outer latency requirement.
In order on the basis of guaranteeing messaging service end performance, extend the application range of delay delivery process, and improves and prolong When the accuracy delivered, the embodiment of the invention provides a kind of message delay delivering methods.
Message delay delivering method provided in an embodiment of the present invention is described in detail below.
Message delay delivering method provided in an embodiment of the present invention can be applied to messaging service end, such as Broker.
The embodiment of the invention provides a kind of message delay delivering methods, as shown in Figure 1, may include:
S101 obtains each message for reaching target time of delivery and obtains each index information of each message.
Target time of delivery can be any point-in-time in this application, that is, carries out message delay described herein and throw Method is passed, can avoid the problem of different message of time of delivery is delivered away by the same time.
Each message and each index information are pre-loaded into the memory at messaging service end.
Specifically, be up to from Block file in advance target time of delivery each message and each message it is each A index information is loaded onto the memory at messaging service end.
Block file is logic storage concept, it can be understood as the file in messaging service end is in messaging service end Different from the part of Commit Log, wherein Commit Log is for storing message body.
Block file is corresponding with time of delivery section, i.e. the corresponding Block file of a time of delivery section.It can also manage Solution is every the time of delivery section one Block file of generation.Time of delivery is saved in the Block file is located at the time of delivery Message and the corresponding index information of message in section.
Index information is used for the storage location etc. of description messages.
Time of delivery is the time that message is delivered.As messaging service termination receives the message of message manufacturing side transmission When, not directly by the message dilivery, but redelivered when reaching delay time of delivery.Wherein, it reaches and delivers in current time When the time, which can be referred to as to target time of delivery.
S102 sends the message to the Commit Log at messaging service end for each message, and the message is corresponding Index information be sent to the consumption queue at information consumption end so that information consumption end is according to index information from Commit Log The message is obtained, and message is consumed.
Commit Log can be the file for storing message body.Specifically, wherein store and disappear in Commit Log Using the mode of sequence addition when breath, according to the chronological order for receiving message, successively append (addition) arrives end of file.
Consume Queue (consumption queue): the distributed Queue (queue) of consumer's maintenance, Topic (channel) are patrolled It is divided into many Queue on volume.Each Queue can only be by a consumer spending.The newest offset of message can be recorded in Queue Amount and the newest progress of consumption etc..
The embodiment of the present invention can be applied in message system RocketMQ.The mistake that message is consumed in RocketMQ Journey can be information consumption end by the information in self-consumption queue, obtains and disappears from the Commit Log at messaging service end Breath, and message is consumed.
Because message is stored in the Block file at information consumption end in the embodiment of the present invention.In this way, for information consumption End process of consumption may be implemented, when being put at the beginning of the time of delivery section that target time of delivery is located at, by each message with And each index information is from the memory that Block file is loaded onto messaging service end, and when reaching target time of delivery, for The each message for reaching target time of delivery, sends the message to the Commit Log at messaging service end, and by the message pair The index information answered is sent to the consumption queue at information consumption end.So that information consumption end is by acquiring index information, from disappearing It ceases in the Commit Log of server-side and obtains message, and message is consumed.Specifically, information consumption end obtains message, and The process consumed to message is referred to existing mode, just repeats no more here.
In the embodiment of the present invention, the delay that the message that time of delivery is any point-in-time may be implemented is delivered, and can satisfy The latency requirement of any delay dimension, the application range of extension delay delivery process, and improve the flexibility that message delay is delivered.
The accurate delivery to message can be realized according to the different delayed time demand of different messages simultaneously, improve delay and deliver Accuracy.
In a kind of optional embodiment of the present invention, is obtaining each message for reaching target time of delivery and obtaining each Before each index information of message, as shown in Fig. 2, can also include:
S103, when receiving the message of message manufacturing side transmission, determines that the target of the message is thrown for each message Pass the time.
In a kind of achievable mode, the message manufacturing side sends the message pair when sending message to messaging service end The time to be delayed answered delivers as the message needs to be delayed 2 seconds, then the message corresponding time to be delayed is 2 seconds.Messaging service After termination receives the time to be delayed, the corresponding time of delivery of the message can be determined, as current time is in conjunction with current time 40 divide 30 seconds when 15, and the message corresponding time to be delayed is 2 seconds, then when can determine that the corresponding time of delivery of the message is 15 40 points 32 seconds.
In the achievable mode of another kind, the message manufacturing side is when sending message, when can send the delivery of the message simultaneously Between.In this way, messaging service end can directly receive the corresponding time of delivery of the message.
S104 determines the time of delivery section that target time of delivery is located at.
The message is saved Block file corresponding to time of delivery section by S105, and by the corresponding index information of the message It saves to Block file.
Message is saved by Block file in the embodiment of the present invention.I.e. when receiving the message of message manufacturing side transmission, Message is cached into Block file.
Block file is corresponding with time of delivery section, i.e. the corresponding Block file of a time of delivery section.It can also manage Solution is every the time of delivery section one Block file of generation.Time of delivery is saved in the Block file is located at the time of delivery Message and the corresponding index information of message in section.
Time of delivery section can determine according to actual needs.It such as can be 30 minutes, 1 hour, 2 hours.The present invention one In the achievable mode of kind, determine that time of delivery section is 1 hour.That is an a hour corresponding Block file.Such as by time of delivery At 11 00 divide 00 second to 11 when 59 message divided 59 seconds save to Block file 1, while the corresponding index information of message being protected Deposit to Block file 1, by time of delivery at 12 00 divide 00 second to 12 when 59 message divided 59 seconds save to Block file 2, The corresponding index information of message is saved to Block file 2 simultaneously, etc..
When determining the corresponding target time of delivery of the message, determine which Block file is the message is saved in, i.e., Determine the time of delivery section that target time of delivery is located at.Such as 30 divide 01 second when determining that the corresponding time of delivery of the message is 11, The message is saved to Block file 1, while the corresponding index information of the message being saved to Block file 1.
In a kind of optional embodiment of the present invention, subfile can be established in Block file, by message and message pair The index information answered is retained separately.
Specifically, which is saved into Block file corresponding to time of delivery section, may include: to save the message To message file, message file is the subfile of the corresponding Block file of time of delivery section.Such as, message file can be Block Log file in file.
The corresponding index information of the message is saved to Block file, comprising:
The corresponding index information of the message is saved to index file, index file is the corresponding Block of time of delivery section The subfile of file.Such as, index file can be the Index file in Block file.Index file is it can be appreciated that record The private file of message repository location.
Simple to understand, Index file saves message meta-data (meta), such as index information;Log file is for saving message Itself.Wherein, log file and Index file can also be further divided into small segement (block), to facilitate management.
In the embodiment of the present invention when receiving message, message is saved to Block file, it is understood that for message into Enter Block file to be cached, when reaching target time of delivery, obtains the message for reaching time of delivery and message is corresponding Index messages, and the Commit Log at messaging service end is sent a message to, index information is sent to the consumption team of consumption terminal Column.It so, it is possible to avoid that message is saved in Commit Log when receiving message, to the shadow of the performance of message server-side It rings.
On the basis of the above embodiments, it is saved by the message to time of delivery in a kind of optional embodiment of the present invention The corresponding Block file of section, and the corresponding index information of the message is saved to Block file, can also include:
It is each by being saved in the corresponding Block file of time of delivery section when being put at the beginning of reaching time of delivery section A message is loaded onto the memory at messaging service end;And by each message saved in the corresponding Block file of time of delivery section Each index information is loaded onto the memory at messaging service end.
Time of delivery section is the time range of a time of delivery, and point is the time model at the beginning of time of delivery section Point at the beginning of enclosing.For example, time of delivery section is 1 hour, including time range: when 11 00 divide 00 second to 11 when 59 divide 59 Second, then when can determine 11 00 divide 00 second be the time of delivery section at the beginning of point.
Specifically, when message is in the message file saved into Block file, time of delivery section is corresponding The each message saved in Block file, is loaded onto the memory at messaging service end, may include:
The message file including each information is obtained from Block file;Message file is loaded onto messaging service end Memory.
When putting at the beginning of reaching time of delivery section, the corresponding message file of time of delivery section is obtained, and should Message file is loaded onto the memory at messaging service end.
It is when the corresponding index information of message is in the index file saved into Block file, time of delivery section is right Each index information of each message saved in the Block file answered, is loaded onto the memory at messaging service end, may include:
The index file including each index information is obtained from Block file;Index file is loaded onto messaging service The memory at end.
When putting at the beginning of reaching time of delivery section, the corresponding index file of time of delivery section is obtained, and should Index file is loaded onto the memory at messaging service end.
On the basis of the above embodiments, in a kind of optional embodiment of the present invention, time of delivery section is corresponding Each index information of each message saved in Block file, is loaded onto after the memory at messaging service end, can also wrap It includes:
As shown in figure 3, may include:
S301 divides time of delivery section, obtains the corresponding each time of delivery of time of delivery section.
In the embodiment of the present invention, when being put at the beginning of reaching time of delivery section, by the corresponding Block of time of delivery section Each index information of each message saved in file after being loaded onto the process of the memory at messaging service end, can will be delivered Period is finely divided, and then according to the time of delivery after subdivision, the corresponding index information of each time of delivery is saved respectively.
Specifically, time of delivery section can be divided according to prefixed time interval.Wherein, prefixed time interval can To determine according to actual needs.In order to can be as accurate as the second, time of delivery section can be divided into using the second as interval.The present invention one In the achievable mode of kind, time of delivery section is 1 hour, and time of delivery section can be divided into 3600 parts, determined every one second One time of delivery.If time of delivery section is 30 minutes, time of delivery section can be divided into 1800 parts, determined every one second One time of delivery.
If time of delivery section includes time range: when 11 00 divide 00 second to 11 when 59 divide 59 seconds, prefixed time interval 1 Second, which is divided are as follows: when 11 00 when dividing 00 second, 11 00 when dividing 01 second, 11 00 divide 02 second ..., 01 divides 00 when 11 Second ..., 11 when 59 divide 59 seconds, 3600 time points.
S302 saves the corresponding index information of the time of delivery corresponding to the time of delivery for each time of delivery Chained list slot position.
After division obtains the corresponding each time of delivery of time of delivery section, it can be determined for each time of delivery corresponding Chained list slot position, and by the index messages for the message that time of delivery is the time of delivery, it saves to the corresponding chained list of the time of delivery In slot position.
Specifically, it can establish the corresponding relationship of time of delivery Yu chained list slot position, and according to the corresponding relationship by each throwing Time corresponding index information is passed to save into corresponding chained list slot position.As shown in table 1 below.
Table 1
In step S101: each index information of each message is obtained, as shown in figure 4, may include:
S1011 determines the corresponding target chained list slot position of the target time of delivery of the message for each message.
Target time of delivery includes in the corresponding each time of delivery of time of delivery section.
S1012 obtains the index information of the message from target chained list slot position.
After determining the message corresponding target time of delivery, it can be closed according to time of delivery is corresponding with chained list slot position System, determines the corresponding target chained list slot position of the target time of delivery.Such as determined according to upper table 1.Such as determine the corresponding target of message Time of delivery is time of delivery 1, then can determine corresponding chained list slot position 1.Disappear in this way, this can be obtained from chained list slot position 1 The index information of breath.
The embodiment of the invention also provides a specific embodiments, as shown in Figure 5.
A1, the producer produces message by the message manufacturing side, and sends a message to messaging service end, such as Broker.
A2 determines the time of delivery of the message after messaging service termination receives message.
Specifically, the message manufacturing side is when sending message to messaging service end, while it is corresponding to be delayed to send the message Time delivers as the message needs to be delayed 2 seconds, then the message corresponding time to be delayed is 2 seconds.Messaging service termination receives this After time to be delayed, the corresponding time of delivery of the message can be determined in conjunction with current time, 40 divide 30 when such as current time being 15 Second, the message corresponding time to be delayed is 2 seconds, then can determine and 40 divide 32 seconds when the corresponding time of delivery of the message is 15. Alternatively, the message manufacturing side when sending message, can send the time of delivery of the message simultaneously.In this way, messaging service end can be with Directly receive the corresponding time of delivery of the message.
A3 determines the corresponding time of delivery section of the time of delivery, further determines that the corresponding Block text of the time of delivery section Part, and the message is saved to the Block file, while the corresponding index of the message being saved to the Block file, wherein The index information is used to illustrate the storage location of the message.Message is set to enter corresponding Block according to the time of delivery of message File cache.
An a hour corresponding Block file in the embodiment of the present invention, i.e., it can be appreciated that time of delivery Duan Weiyi A hour.A title can be determined for each Block file, to distinguish over other Block files.Such as, 2018041812, 2018041813,…,2018041819.Specifically, all message of the time of delivery at 12 can be saved to Block text Part: in 2018041812, i.e., by time of delivery at 12 00 divide 00 second to 12 when 59 message divided 59 seconds save to Block text Part: in 2018041812.It so realizes, saves message to corresponding Block file according to time of delivery.
While saving message, the corresponding index information of message is saved.The index messages are used for the storage of description messages Position when so as to need to obtain the message, addresses, to search and obtain the message according to the index information.Specifically, Ke Yitong It crosses different subfiles and saves message and index information respectively.As the corresponding Block file of each time of delivery section can wrap Include the Index file and log file for saving message, wherein log file is for storing time of delivery in the time of delivery section Message, Index file is for storing the corresponding index information of message.
A4, loading messages and index information.
The point at the beginning of current time is time of delivery section, then from the corresponding Block file of the time of delivery section Each message and each message corresponding index information of the time of delivery in the time of delivery section are obtained, and when by the delivery Between each message in section and the corresponding index information of each message be loaded onto memory, in order to operate.
Wherein it is possible to calculate chained list slot position.
Specifically, the concept of time wheel (TimeWheel) can be introduced.Time wheel can be understood as temporal logic concept. Time of delivery section is 1 hour, and time wheel can be divided into 3600 slot positions, each slot position (Tick) is 1 second corresponding.Simple reason Solution, the dynamic slot position of time rotation indicate that it's one second has past the time.Time rotation moves the time for indicating different to different slot positions Point.
The corresponding chained list slot position of index information that each message in current time of delivery can be calculated corresponds to time wheel Which slot position.And the corresponding relationship of index information and chained list slot position can be saved to chained list, and the chained list is sent to consumption Queue, so as to which the index information in the chained list slot position can be directly acquired according to chained list slot position.
A5, when reaching target time of delivery, messaging service end can obtain time of delivery from memory as target throwing Pass each message and the corresponding index information of each message of time.And it is directed to each message, send the message to message The Commit Log of server-side, and the corresponding index information of the message is sent to the consumption queue at information consumption end.
So that information consumption end obtains the message according to index information from Commit Log, and carries out to message Consumption realizes that consumer passes through consumption of the information consumption end to message.
In the embodiment of the present invention, the delay message of any time can be supported, i.e. support message delay any time is delivered. Such as can be applied to scene: member's business releases a certain new equity, and 00:00:00 is formally effective.It may be needed in existing mode Relevant departments, neighbouring morning go to produce again.Business department even can shift to an earlier date week age in the embodiment of the present invention, will be in equity Hold and sends in message queue MQ in advance.After time of delivery has arrived, equity content can be automatically pushed on each end by MQ.It realizes To the delay of any time of message in service application.
And save message into Block in the embodiment of the present invention, completely new message storage mode is opened, when message is prolonged When reach after, i.e., after the time of delivery of arrival message, then re-start primary message storage and forwarding, can further protect Demonstrate,prove the performance at messaging service end.
The embodiment of the invention provides a kind of message delay delivery apparatus, as shown in fig. 6, it is applied to messaging service end, packet It includes:
Obtain module 601, for obtains reach target time of delivery each message and each message of acquisition it is each Index information;Each message and each index information are pre-loaded into the memory at messaging service end;Target time of delivery Including any point-in-time;
Sending module 602, for sending the message to the Commit Log at messaging service end for each message, and The corresponding index information of the message is sent to the consumption queue at information consumption end so that information consumption end according to index information from The message is obtained in Commit Log, and message is consumed.
In the embodiment of the present invention, the delay that the message that time of delivery is any point-in-time may be implemented is delivered, and can satisfy The latency requirement of any delay dimension, the application range of extension delay delivery process, and improve the flexibility that message delay is delivered.
Optionally, the device further include:
First determining module, for being directed to each message, when receiving the message of message manufacturing side transmission, determining should The target time of delivery of message;
Second determining module, the time of delivery section being located at for determining target time of delivery;
First preserving module, for the message to be saved Block file corresponding to time of delivery section, and by the message pair The index information answered is saved to Block file.
Optionally, the device further include:
Loading module, when for being put at the beginning of reaching time of delivery section, by the corresponding Block text of time of delivery section The each message saved in part, is loaded onto the memory at messaging service end;And it will be saved in the corresponding Block file of time of delivery section Each message each index information, be loaded onto the memory at messaging service end.
Optionally, the first preserving module, specifically for saving the message to message file, message file is time of delivery The subfile of the corresponding Block file of section;
Loading module, specifically for obtaining the message file including each information from Block file;By message file plus It is loaded onto the memory at messaging service end;
First preserving module, specifically for saving the corresponding index information of the message to index file, index file is The subfile of the corresponding Block file of time of delivery section;
Loading module, specifically for obtaining the index file including each index information from Block file;It will index text Part is loaded onto the memory at messaging service end
Optionally, the device further include:
Division module obtains the corresponding each time of delivery of time of delivery section for dividing to time of delivery section;
Second preserving module saves the corresponding index information of the time of delivery to this for being directed to each time of delivery The corresponding chained list slot position of time of delivery;
Module 601 is obtained, is specifically used for being directed to each message, determines the corresponding object chain of target time of delivery of the message Table slot position;Target time of delivery includes in the corresponding each time of delivery of time of delivery section;It is obtained from target chained list slot position The index information of the message.
It should be noted that message delay delivery apparatus provided in an embodiment of the present invention is delivered using above-mentioned message delay The device of method, then all embodiments of above-mentioned message delay delivering method are suitable for the device, and can reach it is identical or Similar beneficial effect.
The embodiment of the invention also provides a kind of message delay delivery devices, as shown in fig. 7, comprises processor 701, communication Interface 702, memory 703 and communication bus 704, wherein processor 701, communication interface 702, memory 703 are total by communication Line 704 completes mutual communication.
Memory 703, for storing computer program;
Processor 701 when for executing the program stored on memory 703, realizes message delay in above-described embodiment The method and step of delivering method.
In the embodiment of the present invention, the delay that the message that time of delivery is any point-in-time may be implemented is delivered, and can satisfy The latency requirement of any delay dimension, the application range of extension delay delivery process, and improve the flexibility that message delay is delivered.
The communication bus that above-mentioned message delay delivery device is mentioned can be Peripheral Component Interconnect standard (Peripheral Component Interconnect, abbreviation PCI) bus or expanding the industrial standard structure (Extended Industry Standard Architecture, abbreviation EISA) bus etc..The communication bus can be divided into address bus, data/address bus, control Bus processed etc..Only to be indicated with a thick line in figure convenient for indicating, it is not intended that an only bus or a type of total Line.
Communication interface is for the communication between above-mentioned message delay delivery device and other equipment.
Memory may include random access memory (Random Access Memory, abbreviation RAM), also may include Nonvolatile memory (non-volatile memory), for example, at least a magnetic disk storage.Optionally, memory may be used also To be storage device that at least one is located remotely from aforementioned processor.
Above-mentioned processor can be general processor, including central processing unit (Central Processing Unit, Abbreviation CPU), network processing unit (Network Processor, abbreviation NP) etc.;It can also be digital signal processor (Digital Signal Processing, abbreviation DSP), specific integrated circuit (Application Specific Integrated Circuit, abbreviation ASIC), field programmable gate array (Field-Programmable Gate Array, Abbreviation FPGA) either other programmable logic device, discrete gate or transistor logic, discrete hardware components.
In another embodiment provided by the invention, a kind of computer readable storage medium is additionally provided, which can It reads to be stored with instruction in storage medium, when run on a computer, so that computer executes message in above-described embodiment and prolongs When delivering method method and step.
In the embodiment of the present invention, the delay that the message that time of delivery is any point-in-time may be implemented is delivered, and can satisfy The latency requirement of any delay dimension, the application range of extension delay delivery process, and improve the flexibility that message delay is delivered.
In another embodiment provided by the invention, a kind of computer program product comprising instruction is additionally provided, when it When running on computers, so that computer executes the method and step of message delay delivering method in above-described embodiment.
In the embodiment of the present invention, the delay that the message that time of delivery is any point-in-time may be implemented is delivered, and can satisfy The latency requirement of any delay dimension, the application range of extension delay delivery process, and improve the flexibility that message delay is delivered.
In the above-described embodiments, can come wholly or partly by software, hardware, firmware or any combination thereof real It is existing.When implemented in software, it can entirely or partly realize in the form of a computer program product.The computer program Product includes one or more computer instructions.When loading on computers and executing the computer program instructions, all or It partly generates according to process or function described in the embodiment of the present invention.The computer can be general purpose computer, dedicated meter Calculation machine, computer network or other programmable devices.The computer instruction can store in computer readable storage medium In, or from a computer readable storage medium to the transmission of another computer readable storage medium, for example, the computer Instruction can pass through wired (such as coaxial cable, optical fiber, number from a web-site, computer, server or data center User's line (DSL)) or wireless (such as infrared, wireless, microwave etc.) mode to another web-site, computer, server or Data center is transmitted.The computer readable storage medium can be any usable medium that computer can access or It is comprising data storage devices such as one or more usable mediums integrated server, data centers.The usable medium can be with It is magnetic medium, (for example, floppy disk, hard disk, tape), optical medium (for example, DVD) or semiconductor medium (such as solid state hard disk Solid State Disk (SSD)) etc..
It should be noted that, in this document, relational terms such as first and second and the like are used merely to a reality Body or operation are distinguished with another entity or operation, are deposited without necessarily requiring or implying between these entities or operation In any actual relationship or order or sequence.Moreover, the terms "include", "comprise" or its any other variant are intended to Non-exclusive inclusion, so that the process, method, article or equipment including a series of elements is not only wanted including those Element, but also including other elements that are not explicitly listed, or further include for this process, method, article or equipment Intrinsic element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that There is also other identical elements in process, method, article or equipment including the element.
Each embodiment in this specification is all made of relevant mode and describes, same and similar portion between each embodiment Dividing may refer to each other, and each embodiment focuses on the differences from other embodiments.Especially for device, For equipment, computer readable storage medium and computer program product embodiments, since it is substantially similar to the method embodiment, So being described relatively simple, the relevent part can refer to the partial explaination of embodiments of method.
The foregoing is merely illustrative of the preferred embodiments of the present invention, is not intended to limit the scope of the present invention.It is all Any modification, equivalent replacement, improvement and so within the spirit and principles in the present invention, are all contained in protection scope of the present invention It is interior.

Claims (11)

1. a kind of message delay delivering method, which is characterized in that be applied to messaging service end, comprising:
It obtains each message for reaching target time of delivery and obtains each index information of each message;Each message and Each index information is pre-loaded into the memory at the messaging service end;The target time of delivery includes any time Point;
For each message, the Commit Log at the messaging service end is sent the message to, and by the corresponding institute of the message The consumption queue that index information is sent to information consumption end is stated, so that the information consumption end is according to the index information from described The message is obtained in Commit Log, and the message is consumed.
2. the method according to claim 1, wherein reaching each message of target time of delivery in the acquisition And before obtaining each index information of each message, the method also includes:
For each message, when receiving the message of message manufacturing side transmission, when determining that the target of the message is delivered Between;
Determine the time of delivery section that the target time of delivery is located at;
The message is saved into Block file corresponding to the time of delivery section, and by the corresponding index information of the message It saves to the Block file.
3. according to the method described in claim 2, it is characterized in that, it is described the message saved it is right to the time of delivery section The Block file answered, and the corresponding index information of the message is saved to the Block file, the method is also Include:
It, will be in the corresponding Block file of the time of delivery section when being put at the beginning of reaching the time of delivery section The each message saved, is loaded onto the memory at the messaging service end;And it is the corresponding Block of the time of delivery section is literary Each index information of each message saved in part is loaded onto the memory at the messaging service end.
4. according to the method described in claim 3, it is characterized in that, described save the message to the time of delivery section corresponds to Block file, comprising:
The message is saved to message file, the message file is the corresponding Block file of the time of delivery section Subfile;
The each message that will be saved in the corresponding Block file of the time of delivery section is loaded onto the message clothes The memory at business end, comprising:
The message file including each information is obtained from the Block file;
The message file is loaded onto the memory at the messaging service end;
It is described to save the corresponding index information of the message to the Block file, comprising:
The corresponding index information of the message is saved to index file, the index file is that the time of delivery section is corresponding The Block file subfile;
Each index information by each message saved in the corresponding Block file of the time of delivery section, adds It is loaded onto the memory at the messaging service end, comprising:
The index file including each index information is obtained from the Block file;
The index file is loaded onto the memory at the messaging service end.
5. according to the method described in claim 3, it is characterized in that, described that the time of delivery section is corresponding described Each index information of each message saved in Block file is loaded onto after the memory at the messaging service end, the side Method further include:
The time of delivery section is divided, the corresponding each time of delivery of the time of delivery section is obtained;
For each time of delivery, the corresponding index information of the time of delivery is saved into chained list slot corresponding to the time of delivery Position;
The each index information for obtaining each message, comprising:
For each message, the corresponding target chained list slot position of the target time of delivery of the message is determined;The target time of delivery Including in the corresponding each time of delivery of the time of delivery section;
The index information of the message is obtained from the target chained list slot position.
6. a kind of message delay delivery apparatus, which is characterized in that be applied to messaging service end, comprising:
Module is obtained, for obtaining each index letter for reaching each message of target time of delivery and obtaining each message Breath;Each message and each index information are pre-loaded into the memory at the messaging service end;When the target is delivered Between include any point-in-time;
Sending module sends the message to the CommitLog at the messaging service end, and should for being directed to each message The corresponding index information of message is sent to the consumption queue at information consumption end, so that the information consumption end is according to the rope Fuse breath obtains the message from the Commit Log, and consumes to the message.
7. device according to claim 6, which is characterized in that described device further include:
First determining module, when receiving the message of message manufacturing side transmission, determines the message for being directed to each message The target time of delivery;
Second determining module, the time of delivery section being located at for determining the target time of delivery;
First preserving module, for the message to be saved Block file corresponding to the time of delivery section, and by the message pair The index information answered is saved to the Block file.
8. device according to claim 7, which is characterized in that described device further include:
Loading module, when for being put at the beginning of reaching the time of delivery section, by the corresponding institute of the time of delivery section The each message saved in Block file is stated, the memory at the messaging service end is loaded onto;And it is the time of delivery section is corresponding The Block file in each index information of each message for saving, be loaded onto the memory at the messaging service end.
9. device according to claim 8, which is characterized in that first preserving module, specifically for the message is protected It deposits to message file, the message file is the subfile of the corresponding Block file of the time of delivery section;
The loading module, specifically for obtaining the message file including each information from the Block file;By institute State the memory that message file is loaded onto the messaging service end;
First preserving module, specifically for saving the corresponding index information of the message to index file, the rope Quotation part is the subfile of the corresponding Block file of the time of delivery section;
The loading module, specifically for obtaining the index file including each index information from the Block file; The index file is loaded onto the memory at the messaging service end.
10. device according to claim 8, which is characterized in that described device further include:
Division module, for being divided to the time of delivery section, when obtaining the corresponding each delivery of the time of delivery section Between;
Second preserving module saves the corresponding index information of the time of delivery to the delivery for being directed to each time of delivery Time corresponding chained list slot position;
The acquisition module is specifically used for being directed to each message, determines the corresponding target chained list of the target time of delivery of the message Slot position;The target time of delivery includes in the corresponding each time of delivery of the time of delivery section;From the target chained list The index information of the message is obtained in slot position.
11. a kind of message delay delivery device, which is characterized in that including processor, communication interface, memory and communication bus, Wherein, the processor, the communication interface, the memory complete mutual communication by the communication bus;
The memory, for storing computer program;
The processor when for executing the program stored on the memory, realizes any side claim 1-5 Method step.
CN201811626539.2A 2018-12-28 2018-12-28 A kind of message delay delivering method, device and equipment Pending CN109450778A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811626539.2A CN109450778A (en) 2018-12-28 2018-12-28 A kind of message delay delivering method, device and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811626539.2A CN109450778A (en) 2018-12-28 2018-12-28 A kind of message delay delivering method, device and equipment

Publications (1)

Publication Number Publication Date
CN109450778A true CN109450778A (en) 2019-03-08

Family

ID=65542057

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811626539.2A Pending CN109450778A (en) 2018-12-28 2018-12-28 A kind of message delay delivering method, device and equipment

Country Status (1)

Country Link
CN (1) CN109450778A (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110333956A (en) * 2019-05-23 2019-10-15 平安普惠企业管理有限公司 Message storage method, device, medium and electronic equipment in message queue
CN111901224A (en) * 2020-07-24 2020-11-06 中国平安财产保险股份有限公司 Method, device and equipment for loading delayed messages and computer readable storage medium
CN113709214A (en) * 2021-08-04 2021-11-26 北京快乐茄信息技术有限公司 Message processing method and device, electronic equipment and storage medium
CN115022263A (en) * 2022-06-02 2022-09-06 政采云有限公司 Delivery method, device, equipment and storage medium of delay message
CN115242744A (en) * 2022-06-15 2022-10-25 艺龙网信息技术(北京)有限公司 Timing message sending method, system, terminal and storage medium of user-defined time

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104123296A (en) * 2013-04-26 2014-10-29 阿里巴巴集团控股有限公司 Method and device for generating message indexes so as to present messages to receiver
CN104866326A (en) * 2015-06-19 2015-08-26 长沙廖氏软件科技有限公司 Integrated exchange middleware and implementation method thereof
CN105468346A (en) * 2014-09-05 2016-04-06 中兴通讯股份有限公司 Timing event management method, storage method, execution method and corresponding apparatus
US20180063055A1 (en) * 2016-08-26 2018-03-01 Linkedin Corporation Repartitioning a topic in a publish-subscribe message system
US20180091586A1 (en) * 2016-09-26 2018-03-29 Linkedin Corporation Self-healing a message brokering cluster
CN108132845A (en) * 2016-12-01 2018-06-08 阿里巴巴集团控股有限公司 Message storage, delivering method and device and electronic equipment
CN108415759A (en) * 2017-02-09 2018-08-17 阿里巴巴集团控股有限公司 Processing method, device and the electronic equipment of message

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104123296A (en) * 2013-04-26 2014-10-29 阿里巴巴集团控股有限公司 Method and device for generating message indexes so as to present messages to receiver
CN105468346A (en) * 2014-09-05 2016-04-06 中兴通讯股份有限公司 Timing event management method, storage method, execution method and corresponding apparatus
CN104866326A (en) * 2015-06-19 2015-08-26 长沙廖氏软件科技有限公司 Integrated exchange middleware and implementation method thereof
US20180063055A1 (en) * 2016-08-26 2018-03-01 Linkedin Corporation Repartitioning a topic in a publish-subscribe message system
US20180091586A1 (en) * 2016-09-26 2018-03-29 Linkedin Corporation Self-healing a message brokering cluster
CN108132845A (en) * 2016-12-01 2018-06-08 阿里巴巴集团控股有限公司 Message storage, delivering method and device and electronic equipment
CN108415759A (en) * 2017-02-09 2018-08-17 阿里巴巴集团控股有限公司 Processing method, device and the electronic equipment of message

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
AKYS佐毅: ""RocketMQ-01、RocketMQ核心"", 《简书,HTTPS://WWW.JIANSHU.COM/P/DE6E13CF55F5》 *
DEXTERMAN: ""RocketMQ CommitLog And Index"", 《OSCHINA,HTTPS://MY.OSCHINA.NET/DEXTERMAN/BLOG/1797271》 *
杭州.MARK: ""如何在MQ中实现支持任意延迟的消息?"", 《博客园,HTTPS://WWW.CNBLOGS.COM/HZMARK/ P/MQ-DELAY-MSG.HTML》 *

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110333956A (en) * 2019-05-23 2019-10-15 平安普惠企业管理有限公司 Message storage method, device, medium and electronic equipment in message queue
CN111901224A (en) * 2020-07-24 2020-11-06 中国平安财产保险股份有限公司 Method, device and equipment for loading delayed messages and computer readable storage medium
CN113709214A (en) * 2021-08-04 2021-11-26 北京快乐茄信息技术有限公司 Message processing method and device, electronic equipment and storage medium
CN115022263A (en) * 2022-06-02 2022-09-06 政采云有限公司 Delivery method, device, equipment and storage medium of delay message
CN115242744A (en) * 2022-06-15 2022-10-25 艺龙网信息技术(北京)有限公司 Timing message sending method, system, terminal and storage medium of user-defined time
CN115242744B (en) * 2022-06-15 2024-02-02 艺龙网信息技术(北京)有限公司 Timing message sending method, system, terminal and storage medium for self-defining time

Similar Documents

Publication Publication Date Title
CN109450778A (en) A kind of message delay delivering method, device and equipment
CN109726024A (en) A kind of message delay delivering method, device and equipment
CN109684358B (en) Data query method and device
US9608953B1 (en) Systems and methods for transferring message data
US9712631B2 (en) Push notification via file sharing service synchronization
US10225203B2 (en) Scheduled transmission of data
US9037657B2 (en) Systems and methods for peer-to-peer bandwidth allocation
US9497288B2 (en) Subscriber based priority of messages in a publisher-subscriber domain
US9208476B2 (en) Counting and resetting broadcast system badge counters
US20180069915A1 (en) Message switch file sharing
US7970856B2 (en) System and method for managing and distributing assets over a network
US8595322B2 (en) Target subscription for a notification distribution system
CA2993163A1 (en) Scalable, real-time messaging system
KR20140072044A (en) Distributing multi-source push notifications to multiple targets
US20130066980A1 (en) Mapping raw event data to customized notifications
EP3332516A1 (en) Scalable, real-time messaging system
CN111813868B (en) Data synchronization method and device
KR20150037943A (en) Cloud process management
CN106713456A (en) Network bandwidth statistics method and device
CN107959696A (en) A kind of daily record bill processing method and system
US20140226681A1 (en) Centralized task management using a router
CN101610289A (en) The methods, devices and systems of data download and node
CN114531946B (en) Data pushing method, data pushing system and computer program product
US9137276B2 (en) Managing message distribution in a networked environment
CN109560949A (en) A kind of data processing method and management server, business device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20190308