CN112583742A - Message processing method and device - Google Patents

Message processing method and device Download PDF

Info

Publication number
CN112583742A
CN112583742A CN201910938909.4A CN201910938909A CN112583742A CN 112583742 A CN112583742 A CN 112583742A CN 201910938909 A CN201910938909 A CN 201910938909A CN 112583742 A CN112583742 A CN 112583742A
Authority
CN
China
Prior art keywords
delay
target
time
message
queue
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
CN201910938909.4A
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 Gridsum Technology Co Ltd
Original Assignee
Beijing Gridsum 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 Gridsum Technology Co Ltd filed Critical Beijing Gridsum Technology Co Ltd
Priority to CN201910938909.4A priority Critical patent/CN112583742A/en
Publication of CN112583742A publication Critical patent/CN112583742A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • 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

Landscapes

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

Abstract

The embodiment of the application discloses a message processing method, which is provided with a plurality of delay queues, wherein each delay queue corresponds to an expiration time. Specifically, a target delay message with corresponding delay time is obtained; and determining a target delay queue with the delay level matched with the delay time, and pushing the target delay message into the target delay queue. If the remaining time obtained by the difference between the delay time and the target expiration time is less than or equal to 0, pushing the target delay message into a service queue for processing when the survival time of the target delay message in the target delay queue reaches the target expiration time. Therefore, whether the target delay messages in each delay queue need to be processed or not is automatically monitored through the due time of each delay queue, and the target delay messages are pushed into the service queues to be processed under the condition that the target delay messages meet the processing conditions, so that the judgment efficiency and the message processing efficiency are improved without a round-robin mode.

Description

Message processing method and device
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and an apparatus for processing a message.
Background
With the development of science and technology, various communication modes such as e-mail, WeChat, short message and the like are developed. And the delayed message sent by using the communication modes of the mail, the WeChat, the short message and the like is often applied to scenes of activity marketing and the like. For example, the user clicks on a push on the WeChat, and some automatic "return visit" is made to the user, such as pushing a teletext message on the user's birthday.
Currently, whether to process the delay message is often judged by a round-training mode aiming at the delay message. However, this method needs to check whether each delay message reaches the delay time periodically, and once the task amount is large, the efficiency of determining is low, which affects the message processing efficiency.
Disclosure of Invention
In order to solve the above technical problem, the present application provides a message processing method, which has a high determination efficiency, and further improves the processing efficiency of the delayed message.
In a first aspect, an embodiment of the present application provides a message processing method, where a plurality of delay queues are provided, and each delay queue corresponds to an expiration time, where the method includes:
acquiring a target delay message, wherein the target delay message has corresponding delay time;
determining a target delay queue with the expiration time matched with the delay time;
pushing the target delay message into the target delay queue;
if the residual time obtained by the difference between the delay time and the target expiration time is less than or equal to 0, pushing the target delay message into a service queue for processing when the survival time of the target delay message in the target delay queue reaches the target expiration time; and the target expiration time is the expiration time corresponding to the target delay queue.
Optionally, each delay queue corresponds to a credit queue, and the method further includes:
if the survival time of the target delay message in the target delay queue reaches the target expiration time, transferring the target delay message into a credit death queue corresponding to the target delay queue;
and consuming the target delay message in the deadlock queue through a consumption module.
Optionally, the consuming, by the consuming module, the delay message in the deadlock queue includes:
if the consumption module judges that the residual time obtained by the difference between the delay time of the target delay message and the target expiration time is greater than 0, adjusting the delay time in the target delay message to the residual time;
and taking the adjusted target delay message as a new delay message, and executing the step of obtaining the target delay message again.
Optionally, the method further includes:
judging the number of delay messages in all delay queues and judging whether the actual time of the delay messages reaching the consumption module is consistent with the expected time;
and if the number of the delay messages in all the delay queues exceeds a preset threshold value or the actual time does not accord with the expected time, increasing the number of the consumption modules through a preset automatic expansion function.
Optionally, if the plurality of delay queues include a delay queue whose expiration time is greater than or equal to 1 minute, each delay queue corresponds to a delay level, the expiration time is represented as K power of 2, K is 0, 1, 2, … … N, and K is the delay level.
Optionally, the determination method of the target delay queue is as follows:
and taking the delay queue corresponding to the maximum expiration time which is less than or equal to the delay time as the target delay queue.
Optionally, the plurality of delay queues further includes at least 1 delay queue with an expiration time less than 1 minute, and the delay level of the delay queue with an expiration time less than 1 minute is represented by the expiration time.
In a second aspect, an embodiment of the present application provides a message processing apparatus, where the apparatus includes:
the device comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring a target delay message which has corresponding delay time;
a determining unit, configured to determine a target delay queue whose expiration time matches the delay time;
the pushing unit is used for pushing the target delay message into the target delay queue;
a processing unit, configured to, if a remaining time obtained by a difference between the delay time and a target expiration time is less than or equal to 0, push the target delay message into a service queue for processing when a survival time of the target delay message in the target delay queue reaches the target expiration time; and the target expiration time is the expiration time corresponding to the target delay queue.
Optionally, each delay queue corresponds to a credit queue, and the apparatus further includes:
a transfer unit, configured to transfer the target delay message to a deadlock queue corresponding to the target delay queue if the survival time of the target delay message in the target delay queue reaches the target expiration time;
and the consumption unit is used for consuming the target delay messages in all the deadlock queues through the consumption module.
Optionally, the consumption unit is further configured to:
if the consumption module judges that the residual time obtained by the difference between the delay time of the target delay message and the target expiration time is greater than 0, adjusting the delay time in the target delay message to the residual time;
and taking the adjusted target delay message as a new delay message, and calling the acquisition unit to re-execute the step of acquiring the target delay message.
Optionally, if the plurality of delay queues include a delay queue whose expiration time is greater than or equal to 1 minute, each delay queue corresponds to a delay level, the expiration time is represented as K power of 2, K is 0, 1, 2, … … N, and K is the delay level.
Optionally, the determining unit is configured to:
and taking the delay queue corresponding to the maximum expiration time which is less than or equal to the delay time as the target delay queue.
Optionally, the plurality of delay queues further includes at least 1 delay queue with an expiration time less than 1 minute, and the delay level of the delay queue with an expiration time less than 1 minute is represented by the expiration time.
In a third aspect, the present application provides an apparatus, which includes at least one processor, and at least one memory and a bus connected to the processor; the processor and the memory complete mutual communication through the bus; the processor is configured to invoke program instructions in the memory to perform the message processing method of any of the first aspects.
In a fourth aspect, embodiments of the present application provide a storage medium having stored thereon instructions that, when executed by one or more processors, cause an apparatus to perform the message processing method according to any one of the first aspects.
According to the technical scheme, the message processing is carried out on the basis of the delay queues, wherein a plurality of delay queues are arranged, and each delay queue corresponds to one expiration time. Specifically, a target delay message is obtained, and the target delay message has corresponding delay time; and determining a target delay queue with the delay level matched with the delay time, and pushing the target delay message into the target delay queue. If the remaining time obtained by the difference between the delay time and the target expiration time is less than or equal to 0, pushing the target delay message into a service queue for processing when the survival time of the target delay message in the target delay queue reaches the target expiration time. Therefore, the scheme is based on the characteristics of the delay queues, whether the delay messages in each delay queue need to be processed or not can be automatically monitored through the due time of each delay queue, and the target delay messages are pushed into the service queues to be processed under the condition that the target delay messages meet the processing conditions, so that the judgment efficiency is improved without a round-robin mode, and the message processing efficiency is further improved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments described in the present application, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is an exemplary diagram of an application scenario of a message processing method according to an embodiment of the present application;
fig. 2 is a flowchart of a message processing method according to an embodiment of the present application;
fig. 3 is a diagram illustrating an exemplary architecture of a delay module for message processing according to an embodiment of the present application;
fig. 4 is a block diagram illustrating a message processing apparatus according to an embodiment of the present disclosure;
fig. 5 is a block diagram of a device according to an embodiment of the present disclosure.
Detailed Description
In order to make the technical solutions of the present application better understood, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Currently, whether to process the delay message is often judged by a round-training mode aiming at the delay message. However, this method has low judgment efficiency, and once the task amount is large, the time required for the round training is too long, which may affect the message transmission efficiency and even cause system instability.
To this end, the embodiment of the present application provides a message processing method, which may be applied to the scene architecture diagram shown in fig. 1. The figure includes a server 101. The server 101 may be an independent server or a server in a cluster.
The message processing method provided by the embodiment of the application can be applied to the system architecture diagram shown in fig. 1. Included in fig. 1 is a server 101. The server 101 may be an independent server or a server in a cluster.
Specifically, the method performs message processing based on a delay queue manner, wherein a plurality of delay queues are provided, and each delay queue corresponds to an expiration time. The server 101 may obtain a target delay message, which has a corresponding delay time. The server 101 determines a target delay queue with an expiration time matched with the delay time according to the delay time, and pushes the target delay message into the target delay queue. The server 101 determines whether the target delay message needs to be processed, if the remaining time obtained by calculating the difference between the delay time and the target expiration time (the expiration time corresponding to the target delay queue) by the server 101 is less than or equal to 0, when the survival time of the target delay message in the target delay queue reaches the target expiration time, the server 101 pushes the target delay message into a service queue for processing, for example, the target delay message is sent to a user.
Due to the characteristics of the delay queues, whether the delay messages in each delay queue need to be processed or not can be automatically monitored through the due time of each delay queue, and the target delay messages are pushed into the service queues to be processed under the condition that the target delay messages meet the processing conditions, so that the judgment efficiency is improved without a round-robin mode, and the message processing efficiency is further improved.
Next, a message processing method provided by the embodiment of the present application will be described in detail with reference to the accompanying drawings.
Referring to fig. 2, fig. 2 shows a flow chart of a message processing method, the method comprising:
s201, obtaining a target delay message.
The delay message may be generated by a production module, all the delay messages may form a delay message set, and then any delay message is acquired from the delay message set as a target delay message, or the delay message may be instantly produced and instantly distributed, which is not limited in the present application. Each delay message has a corresponding delay time, which is the time required to wait for starting to process the delay message. For example, if the delay time is 1 day, it means that the processing of the delay message is started 1 day after the delay message is generated.
The production module may be represented by a Delay Message Producer (Delay Message Producer), and the production module may be a certain module in a server, may also be another server, and may also be a terminal interacting with the server.
For example, when it is required to implement pushing an image-text Message to a user on the birthday day of the user, the Delay Message Producer may generate a Delay Message so that the server may obtain the Delay Message, and the Delay Message may be used as a target Delay Message.
It should be noted that the Message processing method provided in the embodiment of the present application may be implemented based on a delay function of a Message Queue (MQ), where the MQ may be a rabbitmq, and the rabbitmq is open-source Message agent software that implements an advanced Message Queue protocol. The queue of the rabbitmq allows setting of the expiration time, i.e., the time-to-live allowed for the message in the queue. Based on this function of the rabbitMQ, a delay module architecture for message processing as shown in FIG. 3 is designed.
A plurality of Delay queues can be arranged in a Delay module architecture based on the functional design that a Rabbit MQ allows setting of an expiration time, the Delay queues can be represented by Delay queues, and each Delay queue corresponds to one expiration time.
There are various ways in which the expiration time may be expressed. In some possible implementations, if the plurality of delay queues includes a delay queue whose expiration time is greater than or equal to 1 minute, each delay queue corresponds to a delay level, the expiration time is expressed as K power of 2, K is 0, 1, 2, … … N, and K is a delay level.
Of course, in some cases, the delay time of some delayed messages may be small, and the expiration time of the delay queue is related to the message processing time, so that the expiration time of the delay queue can be set more finely in order to ensure the message processing accuracy. For example, at least 1 delay queue with an expiration time less than 1 minute may be further included in the plurality of delay queues, and the delay level of the delay queue with an expiration time less than 1 minute is represented by the expiration time.
For example, the architecture shown in FIG. 3 includes 23 delay queues, which are provided with Time To Live (TTL), and TTL is 5s, 10s, 30s, 2^0min, 2^1min, 2^2min, 2^3min, 2^4min, 2^5min ^ 2^18min, 2^19min in sequence, where 5s, 10s, 30s are less than 1min, the corresponding delay queues are delay queues with an expiration Time less than 1min, and the levels of the delay queues are respectively represented as delay queue 5s, delay queue 10s, and delay queue 30 s; the remaining delay queues are those with an expiration time greater than or equal to 1 minute, and the levels of the delay queues are denoted as delay queue 1, delay queue 2, … …, and delay queue 19, respectively. The TTL time of the queue with the longest TTL is approximately equal to 364 days and approximately equal to one year, and therefore the expiration time of any time can be covered through the delay queue, and further the processing of delay messages of any time can be supported.
S202, determining a target delay queue with the expiration time matched with the delay time.
Since the plurality of delay queues are provided in this embodiment, it is necessary to determine, for a target delay message, into which delay queue the target delay message is pushed.
It should be noted that, there may be many ways to determine the target delay queue whose expiration time matches the delay time, and in this embodiment, one possible implementation manner is to use the delay queue corresponding to the maximum expiration time that is less than or equal to the delay time as the target delay queue.
For example, the delay time is 60s, and a plurality of delay queues are configured as shown in FIG. 3, wherein the delay queues with the expiration time less than or equal to the delay time include delay queues with TTL of 5s, 10s, 30s, 2^0min, and among the 4 delay queues, the maximum TTL is 2^0min, so the delay queue with TTL of 2^0min can be determined as the target delay queue.
S203, pushing the target delay message into the target delay queue.
S204, if the remaining time obtained by the difference between the target delay time and the target expiration time is less than or equal to 0, when the survival time of the target delay message in the target delay queue reaches the target expiration time, pushing the target delay message into a service queue for processing.
After the target delay queue is determined, pushing the target delay message into the target delay queue, wherein the target delay message can survive in the target delay queue. The survival time of the target delay message is determined by the target expiration time corresponding to the target delay queue, when the survival time of the target delay message in the target delay queue reaches the target expiration time, and if the remaining time obtained by the difference between the delay time and the target expiration time is less than or equal to 0, the target delay message needs to be processed, and then the target delay message is pushed into a service queue for processing.
It should be noted that, in the embodiment of the present application, referring to fig. 3, each delay queue may correspond to one deadlock queue, and if the survival time of the target delay message in the target delay queue reaches the target expiration time, the target delay message may also be transferred to the deadlock queue corresponding to the target delay queue. And then consuming the target delay message in the deadlock queue through a consumption module.
The consumption module may be a user of the target delay message, and may be represented by a DXL provider, and the consumption module may be a certain module in a server, or may be another server, or may be a terminal interacting with the server.
In some cases, after the target Delay Message is pushed into the target Delay queue, the Delay time may still remain relative to the target expiration time, that is, the remaining time obtained by subtracting the Delay time from the target expiration time is greater than 0, in this case, even if the survival time of the Delay Message in the target Delay queue reaches the target expiration time, the processing of the Delay Message does not need to be started, that is, the Delay Message is not pushed into the service queue for processing, but the Delay Message should be pushed into the Delay Message Producer again to regenerate the Delay Message.
Therefore, in a possible implementation manner, the consuming, by the consuming module, the target delay message in the deadlock queue corresponding to the target delay queue may specifically include: if the consumption module judges that the residual time obtained by the difference between the delay time of the target delay message and the target expiration time is greater than 0, the delay time in the target delay message is adjusted to be the residual time. The adjusted target delay message is used as a new delay message, and S201 is executed again.
For example, the delay time of a target delay message is 168min, and a plurality of delay queues are arranged as shown in fig. 3. Since the power of 2, which is the largest power less than 168, is 128, i.e., the maximum expiration time less than or equal to the delay time 168min is 2^7min (i.e., the target expiration time is 128min), the target delay queue is the delay queue corresponding to 2^7min (delay queue 7). Therefore, the target delay message is pushed into the delay queue 7.
After the target delay message expires in the delay queue 7, calculating a remaining time obtained by calculating a difference between the delay time and the target expiration time, namely 168-128 min-40 min, wherein 40min is greater than 0, adjusting the delay time of the target delay message, taking the adjusted target delay message as a new delay message, and re-determining the target delay queue corresponding to the target delay message, wherein the delay time corresponding to the adjusted target delay message is 40 min. The maximum power number of 2 less than 40 is 32, that is, the maximum expiration time less than or equal to the delay time 40min is 2^5min (that is, the target expiration time is 32min), and the target delay queue is the delay queue corresponding to 2^5min (delay queue 5). Therefore, the target delay message is pushed into delay queue 5.
After the target delay message expires in the delay queue 5, calculating the remaining time obtained by calculating the difference between the delay time and the target expiration time to be 40-32-8 min, if 8min is greater than 0, adjusting the delay time of the target delay message, wherein the delay time corresponding to the adjusted target delay message is 8min, taking the adjusted target delay message as a new delay message, and determining the target delay queue corresponding to the target delay message. 8 is exactly the power of 3 of 2, so the delay message is pushed into delay queue 3. Thereby reciprocating.
And then, if the remaining time obtained by calculating the difference between the delay time and the target expiration time is less than 1min, pushing the target delay message into corresponding delay queues corresponding to 5s, 10s and 15s according to the adjusted delay time of the target delay message, wherein the logic is the same as that described above, and the description is omitted here.
It should be noted that, in some cases, a large number of delay messages that need to be consumed at the same time may exist, so that a problem of delay message congestion in the delay queue may occur due to delayed consumption of the delay message by the DXL provider, and the delay message congestion in the delay queue may be embodied as an excessive number of delay messages in the delay queue, or an actual time when the delay message reaches the consuming module does not coincide with an expected time.
Therefore, in this embodiment, in order to avoid the congestion problem of the delay messages in the delay queues as much as possible, the consuming module may be monitored, the number of the delay messages in all the delay queues is determined, and whether the actual time of the delay messages reaching the consuming module matches the expected time is determined. If the number of the delay messages in all the delay queues exceeds a preset threshold value or the actual time does not accord with the expected time, the delay message congestion possibly occurs in the delay queues. Therefore, the number of the consumption modules is increased through the preset automatic expansion function, so that the consumption speed of the consumption modules on the delay messages is increased, the delay messages are consumed in time, and the delay message congestion in the delay queues is avoided. The automatic extension function can be realized by triggering a preset script.
According to the technical scheme, the message processing is carried out on the basis of the delay queues, wherein a plurality of delay queues are arranged, and each delay queue corresponds to one expiration time. Specifically, a target delay message is obtained, and the target delay message has corresponding delay time; and determining a target delay queue with the delay level matched with the delay time, and pushing the target delay message into the target delay queue. If the remaining time obtained by the difference between the delay time and the target expiration time is less than or equal to 0, pushing the target delay message into a service queue for processing when the survival time of the target delay message in the target delay queue reaches the target expiration time. Therefore, the scheme is based on the characteristics of the delay queues, whether the delay messages in each delay queue need to be processed or not can be automatically monitored through the due time of each delay queue, and the target delay messages are pushed into the service queues to be processed under the condition that the target delay messages meet the processing conditions, so that the judgment efficiency is improved without a round-robin mode, and the message processing efficiency is further improved.
In addition, the message processing method provided by the embodiment of the application can support the processing of the delayed message with any delay time.
Meanwhile, under the conditions of high concurrency and large data, the number of the consumption modules can be increased by triggering the preset scripts to automatically expand, the consumption speed of the consumption modules on the delay messages is ensured, and the delay message congestion in the delay queues is avoided.
Based on the foregoing message processing method provided by the embodiment, an embodiment of the present application provides a message processing apparatus, where a plurality of delay queues are provided, and each delay queue corresponds to an expiration time, see fig. 4, where the apparatus includes:
an obtaining unit 401, configured to obtain a target delay message, where the target delay message has a corresponding delay time;
a determining unit 402, configured to determine a target delay queue whose expiration time matches the delay time;
a pushing unit 403, configured to push the target delay message into the target delay queue;
a processing unit 404, configured to, if a remaining time obtained by a difference between the delay time and a target expiration time is less than or equal to 0, push the target delay message into a service queue for processing when a survival time of the target delay message in the target delay queue reaches the target expiration time; and the target expiration time is the expiration time corresponding to the target delay queue.
Optionally, each delay queue corresponds to a credit queue, and the apparatus further includes:
a transfer unit, configured to transfer the target delay message to a deadlock queue corresponding to the target delay queue if the survival time of the target delay message in the target delay queue reaches the target expiration time;
and the consumption unit is used for consuming the target delay message in the deadlock queue through the consumption module.
Optionally, the consumption unit is further configured to:
if the consumption module judges that the residual time obtained by the difference between the delay time of the target delay message and the target expiration time is greater than 0, adjusting the delay time in the target delay message to the residual time;
the adjusted target delay message is used as a new delay message, and the step of acquiring the target delay message is executed by the acquiring unit 401.
Optionally, if the plurality of delay queues include a delay queue whose expiration time is greater than or equal to 1 minute, each delay queue corresponds to a delay level, the expiration time is represented as K power of 2, K is 0, 1, 2, … … N, and K is the delay level.
Optionally, the determining unit is configured to:
and taking the delay queue corresponding to the maximum expiration time which is less than or equal to the delay time as the target delay queue.
Optionally, the plurality of delay queues further includes at least 1 delay queue with an expiration time less than 1 minute, and the delay level of the delay queue with an expiration time less than 1 minute is represented by the expiration time.
The message processing device comprises a processor and a memory, wherein the acquisition unit, the determination unit, the pushing and processing unit and the like are stored in the memory as program units, and the processor executes the program units stored in the memory to realize corresponding functions.
The processor comprises a kernel, and the kernel calls the corresponding program unit from the memory. The kernel can be set to be one or more than one, and the purpose of protecting the quick and accurate processing of the message is realized by adjusting the kernel parameters.
An embodiment of the present invention provides a storage medium on which a program is stored, the program implementing the message processing method when executed by a processor.
The embodiment of the invention provides a processor, which is used for running a program, wherein the message processing method is executed when the program runs.
The embodiment of the invention provides equipment, which comprises at least one processor, at least one memory and a bus, wherein the memory and the bus are connected with the processor; the processor and the memory complete mutual communication through a bus; the processor is used for calling the program instructions in the memory to execute the message processing method. The device herein may be a server, a PC, a PAD, a mobile phone, etc.
The present application further provides a computer program product adapted to perform a program for initializing the following method steps when executed on a data processing device:
acquiring a target delay message, wherein the target delay message has corresponding delay time;
determining a target delay queue with the expiration time matched with the delay time;
pushing the target delay message into the target delay queue;
if the residual time obtained by the difference between the delay time and the target expiration time is less than or equal to 0, pushing the target delay message into a service queue for processing when the survival time of the target delay message in the target delay queue reaches the target expiration time; and the target expiration time is the expiration time corresponding to the target delay queue.
Optionally, each delay queue corresponds to a credit queue, and the method further includes:
if the survival time of the target delay message in the target delay queue reaches the target expiration time, transferring the target delay message into a credit death queue corresponding to the target delay queue;
and consuming the target delay messages in all the confidence-loss queues through the consumption module.
Optionally, the consuming, by the consuming module, the delay message in the deadlock queue includes:
if the consumption module judges that the residual time obtained by the difference between the delay time of the target delay message and the target expiration time is greater than 0, adjusting the delay time in the target delay message to the residual time;
and taking the adjusted target delay message as a new delay message, and executing the step of obtaining the target delay message again.
Optionally, the method further includes:
judging the number of delay messages in all delay queues and judging whether the actual time of the delay messages reaching the consumption module is consistent with the expected time;
and if the number of the delay messages in all the delay queues exceeds a preset threshold value or the actual time does not accord with the expected time, increasing the number of the consumption modules through a preset automatic expansion function.
Optionally, if the plurality of delay queues include a delay queue whose expiration time is greater than or equal to 1 minute, each delay queue corresponds to a delay level, the expiration time is represented as K power of 2, K is 0, 1, 2, … … N, and K is the delay level.
Optionally, the determination method of the target delay queue is as follows:
and taking the delay queue corresponding to the maximum expiration time which is less than or equal to the delay time as the target delay queue.
Optionally, the plurality of delay queues further includes at least 1 delay queue with an expiration time less than 1 minute, and the delay level of the delay queue with an expiration time less than 1 minute is represented by the expiration time.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In one typical configuration, shown in FIG. 5, device 50 includes one or more processors (CPUs) 501, memory 502, and bus 503. The device 50 may also include input/output interfaces, network interfaces, and the like.
The memory may include volatile memory in a computer readable medium, Random Access Memory (RAM) and/or nonvolatile memory such as Read Only Memory (ROM) or flash memory (flash RAM), and the memory includes at least one memory chip. The memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in the process, method, article, or apparatus that comprises the element.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The above are merely examples of the present application and are not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims (10)

1. A message processing method, wherein a plurality of delay queues are provided, each delay queue corresponding to an expiration time, the method comprising:
acquiring a target delay message, wherein the target delay message has corresponding delay time;
determining a target delay queue with the expiration time matched with the delay time;
pushing the target delay message into the target delay queue;
if the residual time obtained by the difference between the delay time and the target expiration time is less than or equal to 0, pushing the target delay message into a service queue for processing when the survival time of the target delay message in the target delay queue reaches the target expiration time; and the target expiration time is the expiration time corresponding to the target delay queue.
2. The method of claim 1, wherein each delay queue corresponds to a credit queue, the method further comprising:
if the survival time of the target delay message in the target delay queue reaches the target expiration time, transferring the target delay message into a credit death queue corresponding to the target delay queue;
and consuming the target delay message in the deadlock queue through a consumption module.
3. The method of claim 2, wherein consuming, by a consuming module, the target latency message in the mortgage queue comprises:
if the consumption module judges that the residual time obtained by the difference between the delay time of the target delay message and the target expiration time is greater than 0, adjusting the delay time in the target delay message to the residual time;
and taking the adjusted target delay message as a new delay message, and executing the step of obtaining the target delay message again.
4. The method of claim 3, further comprising:
judging the number of delay messages in all delay queues and judging whether the actual time of the delay messages reaching the consumption module is consistent with the expected time;
and if the number of the delay messages in all the delay queues exceeds a preset threshold value or the actual time does not accord with the expected time, increasing the number of the consumption modules through a preset automatic expansion function.
5. The method of claim 1, wherein if the plurality of delay queues includes a delay queue with an expiration time greater than or equal to 1 minute, each delay queue corresponds to a delay level, the expiration time is represented by K power of 2, K is 0, 1, 2, … … N, and K is the delay level.
6. The method of claim 1 or 5, wherein the target delay queue is determined by:
and taking the delay queue corresponding to the maximum expiration time which is less than or equal to the delay time as the target delay queue.
7. The method of claim 1, wherein the plurality of delay queues further comprises at least 1 delay queue having an expiration time of less than 1 minute, and wherein the delay level of the delay queue having an expiration time of less than 1 minute is indicated by the expiration time.
8. A message processing apparatus, wherein a plurality of delay queues are provided, each delay queue corresponding to a delay level and an expiration time, the expiration time being associated with the delay level, the apparatus comprising:
the device comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring a target delay message which has corresponding delay time;
a determining unit, configured to determine a target delay queue whose delay level matches the delay time;
the pushing unit is used for pushing the target delay message into the target delay queue;
a processing unit, configured to, if a remaining time obtained by a difference between the delay time and a target expiration time is less than or equal to 0, push the target delay message into a service queue for processing when a survival time of the target delay message in the target delay queue reaches the target expiration time; and the target expiration time is the expiration time corresponding to the target delay queue.
9. An apparatus comprising at least one processor, and at least one memory, bus connected to the processor;
the processor and the memory complete mutual communication through the bus;
the processor is configured to invoke program instructions in the memory to perform the message processing method of any of claims 1-7.
10. A storage medium having stored thereon instructions which, when executed by one or more processors, cause an apparatus to perform the message processing method of any one of claims 1 to 7.
CN201910938909.4A 2019-09-30 2019-09-30 Message processing method and device Pending CN112583742A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910938909.4A CN112583742A (en) 2019-09-30 2019-09-30 Message processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910938909.4A CN112583742A (en) 2019-09-30 2019-09-30 Message processing method and device

Publications (1)

Publication Number Publication Date
CN112583742A true CN112583742A (en) 2021-03-30

Family

ID=75116333

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910938909.4A Pending CN112583742A (en) 2019-09-30 2019-09-30 Message processing method and device

Country Status (1)

Country Link
CN (1) CN112583742A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113961379A (en) * 2021-12-22 2022-01-21 零犀(北京)科技有限公司 Message processing method and device based on man-machine conversation

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108415759A (en) * 2017-02-09 2018-08-17 阿里巴巴集团控股有限公司 Processing method, device and the electronic equipment of message
CN108965164A (en) * 2017-05-17 2018-12-07 北京京东尚科信息技术有限公司 Service request repeating method, device and readable storage medium storing program for executing based on message queue
CN109684108A (en) * 2018-12-26 2019-04-26 江苏满运软件科技有限公司 Implementation method, system, storage medium and the electronic equipment of message queue
US10303530B1 (en) * 2016-06-14 2019-05-28 Chicago Stock Exchange, Inc. System and method for sequentially interleaving undelayed and intentionally delayed executable instructions
CN110245008A (en) * 2018-03-09 2019-09-17 阿里巴巴集团控股有限公司 Timed task processing method, system and equipment

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10303530B1 (en) * 2016-06-14 2019-05-28 Chicago Stock Exchange, Inc. System and method for sequentially interleaving undelayed and intentionally delayed executable instructions
CN108415759A (en) * 2017-02-09 2018-08-17 阿里巴巴集团控股有限公司 Processing method, device and the electronic equipment of message
CN108965164A (en) * 2017-05-17 2018-12-07 北京京东尚科信息技术有限公司 Service request repeating method, device and readable storage medium storing program for executing based on message queue
CN110245008A (en) * 2018-03-09 2019-09-17 阿里巴巴集团控股有限公司 Timed task processing method, system and equipment
CN109684108A (en) * 2018-12-26 2019-04-26 江苏满运软件科技有限公司 Implementation method, system, storage medium and the electronic equipment of message queue

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113961379A (en) * 2021-12-22 2022-01-21 零犀(北京)科技有限公司 Message processing method and device based on man-machine conversation
CN113961379B (en) * 2021-12-22 2022-04-12 零犀(北京)科技有限公司 Message processing method and device based on man-machine conversation

Similar Documents

Publication Publication Date Title
CN110768912B (en) API gateway current limiting method and device
CN106202235B (en) Data processing method and device
CN109561128B (en) Data transmission method and device
CN109391512B (en) Service publishing method and device and electronic equipment
CN107578338B (en) Service publishing method, device and equipment
CN112486915B (en) Data storage method and device
CN111245732A (en) Flow control method, device and equipment
CN113821307B (en) Method, device and equipment for quickly importing virtual machine images
CN110764930B (en) Request or response processing method and device based on message mode
CN112583742A (en) Message processing method and device
CN107391541B (en) Real-time data merging method and device
CN108124021B (en) Method, device and system for obtaining Internet Protocol (IP) address and accessing website
CN112114976A (en) Service processing method, device, equipment and storage medium
CN110958278B (en) API gateway-based data processing method and system and API gateway
CN108628551B (en) Data processing method and device
CN112579639A (en) Data processing method and device, electronic equipment and storage medium
CN112445504A (en) Equipment firmware upgrading method, device and system
KR102071107B1 (en) Method and system for data processing
CN112492532B (en) Interconnection method and device for wide and narrow band system
CN115134373A (en) Data synchronization method and device, storage medium and electronic equipment
CN105763508B (en) Data access method and application server
CN110413427B (en) Subscription data pulling method, device, equipment and storage medium
CN109561123B (en) Token caching method and device
CN114528264A (en) Data synchronization method and system
CN111221648A (en) Application sharing method, device and medium based on spread processor

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: 20210330