Delay message processing method and device, computer equipment and readable storage medium

CN119835336APending Publication Date: 2025-04-15SHENZHEN KEMAI TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411986148.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-31
Publication Date
2025-04-15

Smart Images

  • Figure CN119835336A_ABST
    Figure CN119835336A_ABST
Patent Text Reader

Abstract

The invention relates to a delay message processing method and device, computer equipment and a readable storage medium, and relates to the technical field of computer data communication. The method is applied to a message consumer for monitoring a delay queue. The method comprises the following steps: firstly, generating a delay message with effective survival duration and a version number through global configuration; in the system operation process, if the survival duration of global configuration is changed, the first message consumption end takes out the updated delay message from the delay queue and then transfers the updated delay message to the temporary delay queue. And when the target survival duration of the target delay message in the temporary delay queue reaches the preset survival duration, automatically transferring from the temporary delay queue to the dead message queue. And processing the target delay message in the dead message queue by the message consumption end which monitors the dead message queue. By adopting the method, the survival time of the message can be dynamically modified at any time in the system operation process, the normal operation of the service is ensured, and the method is suitable for various service scenes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer data communications, and in particular to a method, apparatus, computer equipment and readable storage medium for processing delayed messages. Background Art

[0002] Delayed messages are used to solve business needs that require delayed processing. Taking online shopping as an example, users usually do not pay in time after placing an order. At this time, a delayed message needs to be generated to record the expiration time of the order. Orders that have not been paid after the timeout will be automatically canceled through the delayed message mechanism to release the occupied product inventory.

[0003] Currently, message broker software such as RabbitMQ (Rabbit Message Queue) is usually used to generate delayed messages and process delayed messages after the message expires. However, as delayed messages are used more and more widely and application requirements are gradually diversified, RabbitMQ cannot achieve flexible configuration of delayed messages, especially in the configuration of message survival time, which makes it difficult for the current delayed message processing to adapt to various business scenarios. Summary of the invention

[0004] Based on this, it is necessary to provide a delayed message processing method, apparatus, computer equipment, computer-readable storage medium and computer program product that can improve the adaptability of delayed messages in response to the above technical problems.

[0005] In the first aspect, the present application provides a method for processing delayed messages, the method comprising: obtaining global configuration information for delayed messages; updating the message configuration information corresponding to each delayed message to be updated in the delay queue according to the global configuration information, to obtain each target delayed message, wherein the message configuration information includes the target survival time of the target delayed message after being updated based on the global configuration information; transferring each target delayed message from the delay queue to a temporary delay queue; for each target delayed message, when the target survival time of the target delayed message reaches a preset survival time, transferring the target delayed message from the temporary delay queue to a dead letter queue, so as to process the target delayed message in the dead letter queue by monitoring the message consumer end of the dead letter queue.

[0006] In one of the embodiments, the global configuration information includes the global configuration survival time and / or the global configuration version number; the message configuration information corresponding to each delayed message to be updated in the delay queue is updated according to the global configuration information to obtain each target delayed message, including one of the following methods: Method 1: When the global configuration information includes the global configuration survival time, each delayed message waiting in the delay queue is used as a delayed message to be updated, and the message configuration information corresponding to each delayed message to be updated is updated according to the global configuration survival time to obtain each target delayed message; or, according to the adjustment time corresponding to the global configuration information and the message generation time in the message configuration information corresponding to the delayed message, the delayed messages to be updated in the delay queue are determined, and the message configuration information corresponding to each delayed message to be updated is updated according to the global configuration survival time. information, and obtain each target delayed message; Method 2: When the global configuration information includes the global configuration version number, determine each delayed message to be updated in the delay queue according to the global configuration version number and the message version number of the delayed message, obtain the global configuration survival time associated with the global configuration version number, and update the message configuration information corresponding to each delayed message to be updated according to the global configuration survival time to obtain each target delayed message; Method 3: When the global configuration information includes the global configuration survival time and the global configuration version number, determine each delayed message to be updated in the delay queue according to the global configuration version number and the message version number of the delayed message, and update the message configuration information corresponding to each delayed message to be updated according to the global configuration survival time to obtain each target delayed message; wherein, the message configuration information includes the message generation time and the message version number.

[0007] In one of the embodiments, the message configuration information corresponding to each delayed message to be updated is updated according to the globally configured survival time to obtain each target delayed message, including: determining the waiting time of each delayed message according to the globally configured survival time and the waiting time of each delayed message; updating the target survival time in the message configuration information corresponding to the delayed message according to each waiting time to obtain each target delayed message; wherein the waiting time of each delayed message is determined based on the message generation time and the current time in the message configuration information of each delayed message in the delay queue.

[0008] In one of the embodiments, by monitoring the message consumer end of the dead letter queue, the target delayed message in the dead letter queue is processed, including: by monitoring the message consumer end of the dead letter queue, respectively obtaining the message generation time of each target delayed message in the dead letter queue; respectively obtaining the time difference between the message generation time of each target delayed message and the current time, and determining the total waiting time of each target delayed message; when the total waiting time is greater than or equal to the global configuration survival time in the global configuration information, processing the target delayed message.

[0009] In one of the embodiments, when the total waiting time is greater than or equal to the global configuration survival time in the global configuration information, the target delay message is processed, including: when the total waiting time is greater than or equal to the global configuration survival time in the global configuration information, obtaining the business status of the target business to which the target delay message belongs; if the business status indicates that the target business has been completed, executing a message confirmation operation for the target delay message; if the business status indicates that the target business has not been completed, after performing a business cancellation operation on the target business, executing a message confirmation operation for the target delay message.

[0010] In one of the embodiments, the global configuration information includes a global configuration survival time and a global configuration version number; the method also includes: for each new delayed message in the delay queue whose message version number is equal to the global configuration version number, when the actual survival time of the new delayed message reaches the global configuration survival time, the new delayed message is transferred from the delay queue to the dead letter queue; by monitoring the message consumer end of the dead letter queue, the target delayed message in the dead letter queue is processed, including: by monitoring the message consumer end of the dead letter queue, the new delayed message and the target delayed message in the dead letter queue are processed.

[0011] In one of the embodiments, the method also includes: determining a configuration type corresponding to the global configuration information; when the configuration type is a first configuration type, executing a step of updating the message configuration information corresponding to each delayed message to be updated in the delay queue according to the global configuration information to obtain each target delayed message; when the configuration type is a second configuration type, taking each delayed message to be updated as each target delayed message, transferring each target delayed message from the delay queue to a temporary delay queue, and for each target delayed message, when the target survival time of the target delayed message reaches a preset target survival time, transferring the target delayed message from the temporary delay queue to the dead letter queue, so as to process the target delayed message in the dead letter queue by monitoring the message consumer end of the dead letter queue.

[0012] In the second aspect, the present application also provides a delayed message processing device, including: a global configuration module, used to obtain global configuration information for delayed messages; a message configuration update module, used to update the message configuration information corresponding to each delayed message to be updated in the delay queue according to the global configuration information, and obtain each target delayed message, wherein the message configuration information includes the target survival time of the target delayed message after updating based on the global configuration information; a first transfer module, used to transfer each target delayed message from the delay queue to a temporary delay queue; a second transfer module, used to transfer the target delayed message from the temporary delay queue to the dead letter queue for each target delayed message when the target survival time of the target delayed message reaches a preset survival time, so as to process the target delayed message in the dead letter queue by monitoring the message consumer end of the dead letter queue.

[0013] In the third aspect, the present application also provides a computer device, including a memory and a processor, the memory storing a computer program, and the processor implementing the following steps when executing the computer program: obtaining global configuration information for delayed messages; updating the message configuration information corresponding to each delayed message to be updated in the delay queue according to the global configuration information, and obtaining each target delayed message, wherein the message configuration information includes the target survival time of the target delayed message after being updated based on the global configuration information; transferring each target delayed message from the delay queue to a temporary delay queue; for each target delayed message, when the target survival time of the target delayed message reaches a preset survival time, transferring the target delayed message from the temporary delay queue to the dead letter queue, so as to process the target delayed message in the dead letter queue by monitoring the message consumer end of the dead letter queue.

[0014] In a fourth aspect, the present application also provides a computer-readable storage medium having a computer program stored thereon, which implements the following steps when the computer program is executed by a processor: obtaining global configuration information for delayed messages; updating message configuration information corresponding to each delayed message to be updated in the delay queue according to the global configuration information, to obtain each target delayed message, wherein the message configuration information includes the target survival time of the target delayed message after being updated based on the global configuration information; transferring each target delayed message from the delay queue to a temporary delay queue; for each target delayed message, when the target survival time of the target delayed message reaches a preset survival time, transferring the target delayed message from the temporary delay queue to a dead letter queue, so as to process the target delayed message in the dead letter queue by monitoring the message consumer end of the dead letter queue.

[0015] In a fifth aspect, the present application also provides a computer program product, comprising a computer program, which implements the following steps when executed by a processor: obtaining global configuration information for delayed messages; updating the message configuration information corresponding to each delayed message to be updated in the delay queue according to the global configuration information, and obtaining each target delayed message, wherein the message configuration information includes the target survival time of the target delayed message after being updated based on the global configuration information; transferring each target delayed message from the delay queue to a temporary delay queue; for each target delayed message, when the target survival time of the target delayed message reaches a preset survival time, transferring the target delayed message from the temporary delay queue to a dead letter queue, so as to process the target delayed message in the dead letter queue by monitoring the message consumer end of the dead letter queue.

[0016] The above-mentioned delayed message processing method, device, computer equipment, computer-readable storage medium and computer program product are applied to the message consumer end that monitors the delayed queue. The message consumer end first obtains the global configuration information for the delayed messages in the delayed queue, and then updates the message configuration information corresponding to each delayed message to be updated in the delayed queue according to the global configuration information. The message configuration information includes the target survival time of the target delayed message after the global configuration information is updated, thereby obtaining each target delayed message, and completing the survival time adjustment of the delayed message to adapt to the modification of the global configuration information. Each delayed message in the delay queue can wait for consumption according to the survival time determined by the modified global configuration information.

[0017] It should be noted that, based on the processing mechanism of delayed messages in the message queue, such as the delayed queue or the temporary delayed queue, the remaining message survival time of each delayed message in the message queue from the head to the tail of the queue is increased successively, so that the processing order of delayed messages can be consistent with the order of entering the delay queue, that is, the processing order of delayed messages in the message queue is to process the delayed messages from the head to the tail of the queue in sequence. It can also be understood that the delayed messages that enter the message queue first are processed first, so as to ensure the standardization of delayed message processing in the message queue.

[0018] In the present application, the message configuration information corresponding to each delayed message to be updated in the delay queue is updated according to the global configuration information. In the process of obtaining each target delayed message, the update order of the message configuration information of the delayed message updated by the global configuration information is also from the head of the delay queue to the tail of the delay queue, and then by transferring each target delayed message with updated message survival time from the delay queue to a newly created temporary delay queue, that is, the target delayed message obtained by updating first is first transferred and placed in the temporary delay queue. In this way, no matter in the delay queue or the temporary delay queue, the remaining message survival time of each delayed message from the head of the queue to the tail of the queue is increased successively, so that the processing order of the delayed messages is consistent with the order of entering the delay queue, ensuring the standardization of the delayed message processing. At the same time, when the global configuration information is modified, for the "old delayed message" in the delay queue that is waiting for consumption according to the survival time determined by the global configuration information before the configuration is modified, it is not necessary to resend it to the delay queue, so that the "old delayed message" can wait for consumption according to the survival time determined by the global configuration information after the configuration is modified. When the target survival time corresponding to the target delayed message updated according to the modified global configuration information reaches the preset survival time, that is, when the target survival time is less than or equal to the preset survival time, it means that the target delayed message has expired, and the message queue processing mechanism will automatically transfer the target delayed message from the delayed temporary queue to the dead letter queue, and the target delayed message will be processed by the message consumer that monitors the dead letter queue. The entire solution overcomes the technical defect that the current message queue cannot flexibly configure and change the expiration time of the delayed message, which makes the current delayed message processing difficult to adapt to various business scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments of the present application or the related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0020] Figure 1 An application environment diagram of a method for processing delayed messages in one embodiment;

[0021] Figure 2 A flowchart of a method for processing delayed messages in one embodiment;

[0022] Figure 3 A schematic diagram of a process for updating the message survival time in one embodiment;

[0023] Figure 4A schematic diagram of a delayed message processing process in one embodiment;

[0024] Figure 5 A schematic diagram of a process of delaying message processing based on a service status in one embodiment;

[0025] Figure 6 It is a flowchart of a method for processing delayed messages in a specific embodiment;

[0026] Figure 7 is a structural block diagram of a device for processing delayed messages in one embodiment;

[0027] Figure 8 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0028] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0029] The method for processing delayed messages provided in the embodiment of the present application includes: obtaining global configuration information for delayed messages; updating the message configuration information corresponding to each delayed message to be updated in the delay queue according to the global configuration information, and obtaining each target delayed message, wherein the message configuration information includes the target survival time of the target delayed message after being updated based on the global configuration information; transferring each target delayed message from the delay queue to the temporary delay queue; for each target delayed message, when the target survival time of the target delayed message reaches the preset survival time, transferring the target delayed message from the temporary delay queue to the dead letter queue, so as to process the target delayed message in the dead letter queue by monitoring the message consumer end of the dead letter queue. Among them, the message consumer end that monitors the dead letter queue is the second message consumer end.

[0030] The method for processing delayed messages provided in the embodiments of the present application is applied to Figure 1 The delayed message processing system shown in the figure includes a control center 102, a first message consumer terminal 104 for monitoring the delayed queue, and a second message consumer terminal 106 for monitoring the dead letter queue, and the control center 102 is connected to the first message consumer terminal 104 and the second message consumer terminal 106 respectively.

[0031] Optionally, the method for processing delayed messages provided in the embodiments of the present application can be applied to Figure 1The first message consumer 104 in the delayed message processing system shown, the first message consumer 104 obtains global configuration information for delayed messages; updates the message configuration information corresponding to each delayed message to be updated in the delay queue according to the global configuration information, and obtains each target delayed message, wherein the message configuration information includes the target survival time of the target delayed message after being updated based on the global configuration information; transfers each target delayed message from the delay queue to a temporary delay queue; for each target delayed message, when the target survival time of the target delayed message reaches the preset survival time, that is, when the target survival time is less than or equal to the preset survival time, transfers the target delayed message from the temporary delay queue to the dead letter queue, so as to process the target delayed message in the dead letter queue by monitoring the message consumer 106 of the dead letter queue.

[0032] Optionally, the method for processing delayed messages provided in the embodiment of the present application can also be applied to Figure 1 The control center 102 of the delayed message processing system. First, the control center 102 obtains the global configuration information for the delayed message, and instructs the first message consumer 104 to update the message configuration information corresponding to each delayed message to be updated in the delay queue according to the global configuration information, thereby obtaining each target delayed message, wherein the message configuration information includes the target survival time of the target delayed message after being updated based on the global configuration information, and transfers each target delayed message from the delay queue to the temporary delay queue. For each target delayed message, when the target survival time of the target delayed message reaches the preset survival time, that is, when the target survival time is less than or equal to the preset survival time, it is automatically transferred from the temporary delay queue to the dead letter queue. The control center 102 further instructs the second message consumer 106 to process the target delayed message in the dead letter queue.

[0033] Among them, the message consumer end refers to the server end where the message consumer is located, and the first message consumer end refers to the message consumer end that monitors the delay queue, which is used to update the survival time of each delayed message in the delay queue. The delayed message processing system can also include a message production end, and the message production end refers to the server end where the message producer is located. The message producer refers to the producer of the delayed message, which can be understood as the server program that generates the delayed message. The message consumer is the receiver of the delayed message, which can be understood as the server program responsible for obtaining and processing the delayed message.

[0034] It should be noted that delayed messages refer to messages that the message producer specifies a time when sending a message, so that the message will not be received and processed immediately by the message consumer, but will be received and processed by the message consumer after the specified time. Delay queues are queues used to store delayed messages. Dead letter queues are used to store expired delayed messages.

[0035] In one example, RabbitMQ message agent software can be deployed in the delayed message processing system. RabbitMQ is an open source message agent software. RabbitMQ can be used to store and forward messages to ensure reliable delivery of messages from producers to consumers. In addition, RabbitMQ provides a variety of message queue management functions to ensure the reliability and efficient processing of messages. In this way, the delayed message processing system can automatically generate and transmit delayed messages and manage various message queues through RabbitMQ.

[0036] In an exemplary embodiment, Figure 2 As shown, a method for processing delayed messages is provided, and the method is applied to Figure 1 Taking the control center 102 in FIG. 1 as an example, the method includes the following steps:

[0037] Step S202: Acquire global configuration information for delayed messages.

[0038] It is understandable that in actual applications, due to the diversity and complexity of business scenarios, there will be a need for flexible configuration of delayed messages. In this embodiment, the message survival time of delayed messages is mainly flexibly configured. The message survival time refers to the survival time of the delayed message, or the time limit for the delayed message to exist or wait in the delay queue. The global configuration information refers to the relevant information for configuring the delayed message, including the global configuration survival time and / or the global configuration version number. The message survival time of the delayed message can be modified and configured through the global configuration survival time. For example, when the global configuration survival time is set to 30 minutes, it indicates that the time limit for the delayed message to wait in the delay queue is 30 minutes. When the delay message waits in the delay queue for greater than or equal to 30 minutes, the delayed message is transferred from the delay queue to the dead letter queue. The global configuration version number is used to record the number of configuration times of the message survival time. That is, each time the global configuration survival time is adjusted, the global configuration version number can automatically add a positive number. As the number of times the global configuration survival time is adjusted increases, the larger the value corresponding to the global configuration version number, the higher the global configuration version number.

[0039] Optionally, the initial value of the global configuration version number can be set to zero. For example, after the global configuration information is modified and adjusted for the first time, the global configuration version number is increased by 1 based on the initial value 0. At this time, the global configuration version number is 1 or V1. This embodiment does not make any specific limitation on this.

[0040] Optionally, the acquisition of global configuration information for delayed messages may be triggered based on the receipt of a configuration instruction for the message survival time of delayed messages, that is, the receipt of a configuration instruction for modifying the global configuration information, thereby acquiring the global configuration information set according to the configuration instruction. Alternatively, the acquisition of global configuration information for delayed messages may be triggered in a timed acquisition manner, such as a preset time or a preset time interval. Alternatively, the acquisition of global configuration information for delayed messages may be triggered in a real-time acquisition manner, which is not limited in this embodiment.

[0041] Step S204: Update the message configuration information corresponding to each delayed message to be updated in the delay queue according to the global configuration information to obtain each target delayed message.

[0042] Among them, the target delayed message refers to a delayed message whose message survival time has been updated. The message configuration information may refer to the configuration information of the delayed message, which may include but is not limited to the target survival time, the service ID corresponding to the delayed message, the message version number, the message generation time, etc. The target survival time may refer to the current remaining survival time of the delayed message or the target delayed message, or the time the delayed message needs to wait in the delay queue or the target delayed message needs to wait in the temporary delay queue. It can be understood that the target survival time is a variable time value. The longer the waiting time of the delayed message in the delay queue or the longer the waiting time of the target delayed message in the temporary delay queue, the smaller the target survival time, until the target survival time is 0. The message version number refers to the version number of the delayed message, and the message generation time refers to the generation time of the delayed message.

[0043] It should be noted that the message version number in the message configuration information is determined when the delay message is generated according to the global configuration version number in the global configuration information. For example, assuming that at 12:00 on November 26, 2024, the global configuration survival time in the global configuration information is 20 minutes, and the global configuration version number is version 1.0, at 15:00 on November 26, 2024, the global configuration survival time in the global configuration information is modified from 20 minutes to 15 minutes, and the global configuration information has only been modified once, at this time, the global configuration version number is version 2.0. The message version number in the message configuration information corresponding to the delay message generated in the time period from 12:00 on November 26, 2024 to 15:00 on November 26, 2024 is version 1.0. After 15:00 on November 26, 2024, the message version number in the message configuration information corresponding to the delay message generated is version 2.0.

[0044] It is understandable that, assuming that the global configuration information such as the global configuration survival time is modified and adjusted, there will be at least two delayed messages corresponding to the message version numbers in the delay queue. However, the delayed messages in the delay queue can be divided into two types of delayed messages. One type is that the message version number is the same as the current global configuration version number, and the corresponding "new delayed message" indicates that the "new delayed message" is waiting for the message to be consumed according to the currently set global configuration survival time, and can also be regarded as the new delayed message that continues to enter the delay queue; the other type is that the message version number is different from the current global configuration version number, and the corresponding "old delayed message" indicates that the "old delayed message" is waiting for the message to be consumed according to the "old" global configuration survival time set before the currently set global configuration survival time. It is understandable that in order to achieve that each delayed message in the delay queue waits and is consumed according to the currently set global configuration survival time, it is necessary to adjust the target survival time of the "old delayed message" in the delay queue according to the currently set global configuration survival time.

[0045] As an optional implementation, the global configuration information includes the global configuration survival time, and step S204 includes: taking each delayed message waiting in the delay queue as a delayed message to be updated, and updating the message configuration information corresponding to each delayed message to be updated according to the global configuration survival time to obtain each target delayed message; or, determining each delayed message to be updated in the delay queue according to the adjustment time corresponding to the global configuration information and the message generation time in the message configuration information corresponding to the delayed message, and updating the message configuration information of each delayed message to be updated according to the global configuration survival time to obtain each target delayed message.

[0046] In this embodiment, when the global configuration information only includes the global configuration survival time, as an optional implementation, step S204 includes: taking each delayed message waiting in the delay queue as a delayed message to be updated, updating the message configuration information corresponding to each delayed message to be updated according to the global configuration survival time, and obtaining each target delayed message.

[0047] In this embodiment, when the global configuration information only includes the global configuration survival time, in order to adjust the target survival time of the "old delayed message" in the delay queue according to the currently set global configuration survival time, since it is impossible to distinguish between the "new delayed message" and the "old delayed message" in the delay queue, each delayed message waiting in the delay queue can be used as a delayed message to be updated, and then the message configuration information corresponding to each delayed message to be updated is updated according to the global configuration survival time to obtain each target delayed message, so as to achieve the purpose of adjusting the target survival time of the "old delayed message" according to the currently set global configuration survival time, so that each delay message in the delay queue is waited and consumed according to the currently set global configuration survival time.

[0048] In this embodiment, when the global configuration information only includes the global configuration survival time, as another optional implementation, step S204 includes: determining each delayed message to be updated in the delay queue according to the adjustment time corresponding to the global configuration information and the message generation time in the message configuration information corresponding to the delayed message, and updating the message configuration information of each delayed message to be updated according to the global configuration survival time to obtain each target delayed message.

[0049] In this embodiment, when the global configuration information only includes the global configuration survival time, in order to adjust the target survival time of the "old delayed message" in the delay queue according to the currently set global configuration survival time, the "old delayed message" can be first screened out from the delay queue as each delayed message to be updated. It should be noted that the adjustment time refers to the time of adjusting the global configuration information, that is, the delayed messages whose message generation time is later than the adjustment time are taken as the delayed messages to be updated. For example, assuming that the adjustment time of the global configuration information is 12:00 on November 26, 2024, the delayed messages whose message generation time is before 12:00 on November 26, 2024 are taken as the delayed messages to be updated. Exemplarily, the delayed messages corresponding to the message generation times of 12:00 on November 25, 2024, 11:30 on November 26, 2024, 11:59 on November 26, 2024, etc. are the delayed messages to be updated, that is, the "old delayed messages". In this embodiment, there is no need to adjust the target survival time of the "new delayed message" in the delay queue. Only the target survival time of the "old delayed message" in the delay queue needs to be adjusted according to the currently set global configuration survival time.

[0050] As an optional implementation, the global configuration information includes a global configuration version number, and step S204 includes: determining each delayed message to be updated in the delay queue based on the global configuration version number and the message version number of the delayed message; obtaining the global configuration survival time associated with the global configuration version number; updating the message configuration information of each delayed message to be updated based on the global configuration survival time to obtain each target delayed message.

[0051] In this embodiment, when the global configuration information only includes the global configuration version number, in order to adjust the target survival time of the "old delayed messages" in the delay queue according to the currently set global configuration survival time, the "old delayed messages" can be first screened out from the delay queue as the delayed messages to be updated. It should be noted that the delayed messages whose message version numbers are less than the global configuration version number are used as delayed messages to be updated. According to the association between the global configuration version number and the global configuration survival time, the global configuration survival time associated with the global configuration version number is obtained, and the message configuration information of each delayed message to be updated is updated according to the obtained global configuration survival time to obtain each target delayed message. In this way, by obtaining the global configuration survival time associated with the global configuration version number, the accuracy of the global configuration survival time can be ensured, thereby effectively improving the accuracy of message configuration information update according to the global configuration survival time.

[0052] Optionally, the association relationship between the global configuration version number and the global configuration survival time can be pre-stored in an association relationship table, so that the global configuration survival time associated with the global configuration version number can be quickly obtained by directly querying the association relationship table. Of course, in actual applications, other methods can also be used to record the association relationship between the global configuration version number and the global configuration survival time, so as to obtain the global configuration survival time associated with the global configuration version number based on the association relationship, and this embodiment does not limit this.

[0053] As an optional implementation, the global configuration information includes a global configuration survival time and a global configuration version number, and step S204 includes: determining each delayed message to be updated in the delay queue based on the global configuration version number in the global configuration information and the message version number of the delayed message; and updating the message configuration information of each delayed message to be updated based on the global configuration survival time in the global configuration information to obtain each target delayed message.

[0054] In this embodiment, when the global configuration information includes the global configuration version number and the global configuration survival time, the delayed message with a message version number less than the global configuration version number can be directly used as the delayed message to be updated, that is, the "old delayed message" in the delay queue is directly screened out, and then the message configuration information of each delayed message to be updated is directly updated according to the global configuration survival time in the global configuration information to obtain each target delayed message. In this embodiment, only one query operation is required, that is, the global configuration information such as the global configuration version number and the global configuration survival time is directly obtained at one time, so as to achieve the purpose of not adjusting the target survival time of the "new delayed message" in the delay queue, and only adjusting the target survival time of the "old delayed message" according to the currently set global configuration survival time, so that each delayed message in the delay queue waits and is consumed according to the currently set global configuration survival time, reducing the number of indirect information query operations, such as obtaining the global configuration survival time associated with the global configuration version number, the adjustment time corresponding to the global configuration information, and the message generation time in the message configuration information corresponding to the delayed message, etc., which can not only improve the system response rate, but also reduce system resource consumption.

[0055] Optionally, the step of updating the message configuration information of each delayed message to be updated according to the globally configured survival time to obtain each target delayed message includes: determining the waiting time of each delayed message according to the globally configured survival time and the waiting time of each delayed message; updating the target survival time in the message configuration information corresponding to the delayed message according to each waiting time to obtain each target delayed message; wherein the waiting time of each delayed message is determined based on the message generation time and the current time in the message configuration information of each delayed message in the delay queue.

[0056] It should be noted that the specific implementation of the above steps of obtaining each target delay message will be described in detail in subsequent embodiments and will not be described in detail in this embodiment.

[0057] Optionally, each delayed message to be updated may be a delayed message in the delay queue corresponding to a message version number that is different from the global configuration version number in the global configuration information. For example, a delayed message in the delay queue whose message version number is lower than the global configuration version number may be used as a delayed message to be updated; it may also be a delayed message in the delay queue where the message generation time in the message configuration information is later than the adjustment time corresponding to the global configuration information; it may also be each delayed message waiting in the delay queue, which is not limited in this embodiment.

[0058] Optionally, the number of delayed messages to be updated may be 0 or at least one, which is not limited in this embodiment.

[0059] Exemplarily, when the first message consumer detects a change in the global configuration survival time and / or the global configuration version number, the first message consumer may update the message survival time of each delayed message according to the global configuration survival time to obtain an updated target delayed message.

[0060] Optionally, after monitoring changes in the global configuration survival time and / or the global configuration version number, the control center may send a message update instruction to the first message consumer to instruct the first message consumer to update the current survival time of each delayed message according to the global configuration survival time to obtain an updated target delayed message.

[0061] In one example, the first message consumer updates the message survival time of each delayed message to be updated according to the global configuration survival time, and simultaneously updates the message version number of each delayed message to be updated according to the global configuration version number. That is, the message version number of each delayed message to be updated is kept consistent with the global configuration version number, indicating that the message survival time of each delayed message to be updated, that is, the "old delayed message", has been updated according to the global configuration survival time determined by the modified global configuration information.

[0062] In one example, before receiving the message update instruction sent by the control center, the first message consumer can be in a blocked state and will not monitor the delay queue. Only when receiving the message update instruction sent by the control center will it become a working state and monitor the delay queue. After all delayed messages that need to update the message survival time are successfully updated, the first message consumer will enter the blocked state again.

[0063] Step S206: Transfer each target delayed message from the delay queue to the temporary delay queue.

[0064] Among them, the temporary delay queue is a newly created queue for temporarily storing various target delay messages. It can be understood that, considering that new delay messages are still continuously entering the delay queue, in order to ensure the standardization of delayed message processing, in this embodiment, the target delay message that updates the survival time of each message is transferred from the delay queue to a newly created temporary delay queue. In this way, whether in the delay queue or the temporary delay queue, the message survival time of each delayed message from the head of the queue to the tail of the queue is increased in sequence, so that the processing order of the delayed messages can be consistent with the order of entering the delay queue, ensuring the standardization of delayed message processing, and thus improving the efficiency of delayed message processing.

[0065] It should be noted that the target survival time of each delayed message in the delay queue from the head to the tail of the queue is gradually increasing. When the target survival time of the delayed message is 0, it indicates that the waiting time of the delayed message in the delay queue has expired and can be transferred to the dead letter queue for consumption. It is understandable that the delayed messages in the delay queue are transferred to the dead letter queue from the head to the tail of the queue for consumption. It is easy to understand that the waiting time of each delayed message in the delay queue from the head to the tail of the queue is gradually decreasing.

[0066] However, when the global configuration survival time is modified and adjusted, the target survival time of the delayed message at the tail of the delay queue may be less than the target survival time of the delayed message at the head of the queue. For example, as shown in Table 1, Table 1 shows the target survival time of the delayed message in the delay queue A, that is, the remaining waiting time in the delay queue. The delayed messages of the delay queue A from the head to the tail of the queue are: 1, 2, 3, 4, 5, 6, 7 and 8. Assume that: when delayed messages 1-4 are generated, the corresponding global configuration survival time is 30 minutes (minutes), and the global version number is 0. When delayed messages 5-8 are generated, the corresponding global configuration survival time is 15 minutes, and the global version number is 1.0. It can be seen from Table 1 that when the global configuration survival time is modified and adjusted, the target survival time of the delayed message at the tail of the queue is less than the target survival time of the delayed message at the head of the queue, which will lead to the problem that the delayed messages cannot be transferred to the dead letter queue for consumption from the head to the tail of the queue. Therefore, when the global configuration survival time is updated, delayed messages 1-4 will enter the temporary delay queue in Table 2. At this time, the target survival time of delayed messages 1-4, that is, the remaining waiting time, is 0min, 0min, 3min, and 5min respectively.

[0067] It can be understood that when the global configuration survival time is changed from 30 minutes to 15 minutes, the waiting time of delayed messages 1, 2, 3, and 4 in delay queue A is 20 minutes, 15 minutes, 12 minutes, and 10 minutes, respectively.

[0068] It can be understood that the remaining waiting time of delayed message 1 and delayed message 2 in the temporary delay queue is 0, and delayed message 1 and delayed message 2 can be immediately transferred to the dead letter queue for consumption.

[0069] Table 1

[0070] Delay Queue A 8 7 6 5 4 3 2 1 Remaining waiting time (min / minutes) 15 14 13 11 20 18 15 10

[0071] Table 2

[0072] Temporary Delay Queue 4 3 2 1 Remaining waiting time (min / minutes) 5 3 0 0

[0073] Exemplarily, after completing the update of the message survival time of each delayed message, the first message consumer transmits the updated target delayed message to a pre-created temporary delay queue.

[0074] In one example, each time the message survival time is reconfigured, a new temporary delay queue is generated, that is, the temporary delay queue is one-time.

[0075] Step S208, for each target delayed message, when the target survival time of the target delayed message reaches the preset survival time, the target delayed message is transferred from the temporary delay queue to the dead letter queue, so as to process the target delayed message in the dead letter queue by monitoring the message consumer end of the dead letter queue.

[0076] The preset survival time is a preset survival time. Optionally, the preset survival time is 0.

[0077] For example, for each target delayed message, when the target survival time of the target delayed message reaches the preset survival time, that is, the current remaining survival time of the target delayed message is 0, it means that the target delayed message has expired and needs to be transferred to the dead letter queue. After the target delayed message is automatically transferred to the dead letter queue, the second message consumer end that monitors the dead letter queue will automatically process the target delayed message.

[0078] In an optional embodiment, the method for processing delayed messages includes: determining the configuration type corresponding to the global configuration information; when the configuration type is the first configuration type, executing steps 204-208; when the configuration type is the second configuration type, treating each delayed message to be updated as a target delayed message, transferring each target delayed message from the delay queue to the temporary delay queue, and for each target delayed message, when the target survival time of the target delayed message reaches a preset target survival time, transferring the target delayed message from the temporary delay queue to the dead letter queue, so as to process the target delayed message in the dead letter queue by monitoring the message consumer end of the dead letter queue.

[0079] It should be noted that the configuration types corresponding to the global configuration information include a first configuration type and a second configuration type, wherein the first configuration type indicates that the message configuration information of the "old delayed message" in the delay queue needs to be adjusted and updated to adapt to the modified global configuration information, and the second configuration type indicates that the "old delayed message" in the delay queue is applicable to the message configuration information message corresponding to the "old delayed message" itself, and does not need to be adjusted according to the modified global configuration information.

[0080] The configuration type can be determined based on a configuration instruction for modifying the global configuration information. If the instruction information in the configuration instruction includes adjustment according to the modified global configuration information, it indicates that the configuration type is the first configuration type. If the instruction information in the configuration instruction includes no need to adjust according to the modified global configuration information, it indicates that the configuration type is the second configuration type. The instruction information of the configuration instruction can be distinguished by setting different configuration buttons. For example, clicking the first button indicates that the instruction information of the received configuration instruction includes adjustment according to the modified global configuration information. Clicking the second button indicates that the instruction information of the received configuration instruction includes no need to adjust according to the modified global configuration information.

[0081] It is understandable that the association relationship between the configuration instruction of the global configuration information, the global configuration information and the configuration type can be preset, and the configuration type corresponding to the global configuration information is determined based on the association relationship.

[0082] For example, to facilitate understanding of this embodiment, the above Table 1 is used as an example. Among them, the specific implementation of steps 204 to 208 has been described in detail and will not be repeated here. When the configuration type is the second configuration type, it indicates that the "old delayed message" in the delay queue is applicable to the message configuration information message corresponding to the "old delayed message" itself, and there is no need to adjust according to the modified global configuration information. Each delayed message to be updated is used as each target delayed message, and steps 206 to 208 are executed.

[0083] As shown in Table 1, Table 1 shows the target survival time of delayed messages in delay queue A, that is, the remaining waiting time in the delay queue. The delayed messages of delay queue A from the head of the queue to the tail of the queue are: 1, 2, 3, 4, 5, 6, 7 and 8. Assume that: when delayed messages 1-4 are generated, the corresponding global configuration survival time is 30 minutes, and the global version number is 0. When delayed messages 5-8 are generated, the corresponding global configuration survival time is 15 minutes, and the global version number is 1.0. It can be seen from Table 1 that when the global configuration survival time is modified and adjusted, the target survival time of the delayed message at the tail of the queue is less than the target survival time of the delayed message at the head of the queue, which will lead to the problem that the delayed messages cannot be transferred to the dead letter queue for consumption in sequence from the head of the queue to the tail of the queue. Therefore, in order to avoid the problem that the delayed messages cannot be transferred to the dead letter queue for consumption in sequence from the head of the queue to the tail of the queue, each delayed message to be updated, that is, the "old delayed message", is transferred to the temporary delay queue, such as Figure 3 As shown, at this time, the target survival time of delayed messages 1-4, that is, the remaining waiting time, remains unchanged, which are 10min, 15min, 18min, and 10min respectively, so that even after the global configuration information is changed, the "old delayed messages" in the delay queue can be consumed normally, and the "new delayed messages" in the delay queue can also be consumed normally.

[0084] Table 3

[0085] Temporary delay queue 4 3 2 1 Remaining waiting time (min / minutes) 20 18 15 10

[0086] Then, for each target delayed message, when the target survival time of the target delayed message reaches the preset target survival time, that is, the target survival time is 0, the target delayed message has reached the consumption time limit, and the target delayed message is transferred from the temporary delay queue to the dead letter queue, so as to process the target delayed message in the dead letter queue by monitoring the message consumer end of the dead letter queue.

[0087] This embodiment is applied to the first message consumer end that monitors the delay queue. The first message consumer end first obtains the global configuration information for the delayed messages in the delay queue, and then updates the message configuration information corresponding to each delayed message to be updated in the delay queue according to the global configuration information. The message configuration information includes the target survival time of the target delayed message after being updated based on the global configuration information, thereby obtaining each target delayed message, and completing the survival time adjustment of each delayed message to be updated to adapt to the modification of the global configuration information. Each delayed message in the delay queue can wait for consumption according to the survival time determined by the modified global configuration information, such as the target survival time.

[0088] It should be noted that, based on the processing mechanism of delayed messages in the message queue, such as the delayed queue or the temporary delayed queue, the remaining message survival time of each delayed message in the message queue from the head to the tail of the queue is increased successively, so that the processing order of delayed messages can be consistent with the order of entering the delay queue, that is, the processing order of delayed messages in the message queue is to process the delayed messages from the head to the tail of the queue in sequence. It can also be understood that the delayed messages that enter the message queue first are processed first, so as to ensure the standardization of delayed message processing in the message queue.

[0089] In this embodiment, the message configuration information corresponding to each delayed message to be updated in the delay queue is updated according to the global configuration information. In the process of obtaining each target delayed message, the update order of the message configuration information of the delayed message by the global configuration information is also from the head of the delay queue to the tail of the delay queue, and then by transferring each target delayed message with updated message survival time from the delay queue to a newly created temporary delay queue, that is, the target delayed message obtained by updating first is first transferred and placed in the temporary delay queue. In this way, no matter in the delay queue or the temporary delay queue, the remaining message survival time of each delayed message from the head of the queue to the tail of the queue is increased successively, so that the processing order of the delayed messages is consistent with the order of entering the delay queue, ensuring the standardization of the delayed message processing. At the same time, when the global configuration information is modified, for the "old delayed message" in the delay queue that is waiting for consumption according to the survival time determined by the global configuration information before the configuration is modified, it is not necessary to resend it to the delay queue, so that the "old delayed message" can wait for consumption according to the survival time determined by the global configuration information after the configuration is modified. When the target survival time corresponding to the target delayed message updated according to the modified global configuration information reaches the preset survival time, that is, when the target survival time is less than or equal to the preset survival time, it means that the target delayed message has expired, and the message queue processing mechanism will automatically transfer the target delayed message from the delayed temporary queue to the dead letter queue, and the second message consumer that monitors the dead letter queue will process the target delayed message. The entire solution overcomes the technical defect that the current message queue cannot flexibly configure and change the expiration time of the delayed message, which makes the current delayed message processing difficult to adapt to various business scenarios.

[0090] In an exemplary embodiment, Figure 3 As shown, the message configuration information corresponding to each delayed message to be updated in the delay queue is updated according to the global configuration information to obtain each target delayed message, including:

[0091] Step S302: Determine the waiting time for each delayed message according to the global configuration survival time and the waiting time of each delayed message.

[0092] The waiting time can be understood as the length of time that the delayed message has survived. The waiting time of each delayed message can be determined based on the message generation time and the current time in the message configuration information of each delayed message in the delay queue. The waiting time can be understood as the length of time that the delayed message can still survive, and can also be regarded as the length of time that the delayed message needs to wait until it expires or is consumed.

[0093] When the first message consumer updates the message survival time, it can first obtain the message generation time of each delayed message from the message configuration information of the delayed message, and then calculate the time difference between the message generation time and the current time to obtain the length of time the delayed message has survived, that is, the waiting time of the delayed message. Then, the difference between the globally configured survival time and the survival time is calculated to obtain the length of time the delayed message can still survive, that is, the waiting time of the delayed message. It can be understood that when the difference between the globally configured survival time and the survival time is negative, it indicates that the delayed message has expired and can be transferred from the delay queue to the dead letter queue, or the expired delayed message can be transferred from the delay queue to the temporary delay queue, and then transferred from the temporary delay queue to the dead letter queue for consumption.

[0094] Optionally, the waiting time of the delayed message can be obtained by taking the absolute value of the time difference between the message generation time and the current time.

[0095] For example, assuming that the message generation time of delayed message A is 12 o'clock, and the globally configured survival time corresponding to 12 o'clock is 20 minutes, if the globally configured survival time of delayed message A is modified at 12:10, for example, the globally configured survival time is modified from 20 minutes to 15 minutes, it indicates that user needs have changed. By shortening the globally configured survival time, the delayed message A expires or is consumed in advance. At this time, the waiting time of delayed message A is 10 minutes, which is obtained by the difference between the current time 12:10 and the message generation time 12 o'clock. The waiting time of delayed message A is determined by the difference between the modified global configuration time and the waiting time, that is, the waiting time of delayed message A is 15min-10min=5min.

[0096] Similarly, for example, assuming that the message generation time of delayed message A is 12 o'clock, and the global configuration duration corresponding to 12 o'clock is 20 minutes, if the global configuration survival time of delayed message A is modified at 12:10, for example, the global configuration survival time is modified from 20 minutes to 30 minutes, it indicates that user needs have changed, and the global configuration survival time has been extended to postpone the expiration or consumption of delayed message A. At this time, the waiting time of delayed message A is 10 minutes, which is obtained by the difference between the current time 12:10 and the message generation time 12 o'clock. The waiting time of delayed message A is determined by the difference between the modified global configuration time and the waiting time, that is, the waiting time of delayed message A is 30 minutes-10 minutes=20 minutes.

[0097] Step S304, obtaining each target delay message according to the target survival time in the message configuration information corresponding to each waiting time update delay message.

[0098] Exemplarily, after calculating the waiting time of each delayed message, the first message consumer updates the target survival time in the message configuration information of each delayed message to the waiting time of the corresponding delayed message, thereby obtaining the target delayed message. It is understandable that the target survival time in the message configuration information of the target delayed message is the survival time re-determined after the global configuration information is modified and adjusted, that is, the remaining survival time or the time to be waited.

[0099] Taking the example in step S302, corresponding to the example of extending the global configuration survival time, the target survival time is updated by delaying the waiting time of message A, and finally the target survival time of the delayed message A is updated to 20 minutes; corresponding to the example of shortening the global configuration survival time, the target survival time is updated by delaying the waiting time of message A, and finally the target survival time of the delayed message A is updated to 5 minutes.

[0100] In this embodiment, the waiting time of each delayed message is calculated according to the global configuration survival time and the waiting time of each delayed message. The target survival time in the message configuration information of the delayed message is updated according to the waiting time to obtain each target delayed message. The accuracy of the target survival time in the message configuration information is ensured, and then the accuracy of processing the target delayed message is ensured when the target survival time of the target delayed message reaches the preset survival time, that is, the target survival time is less than or equal to the preset survival time.

[0101] In an exemplary embodiment, determining each delayed message to be updated in the delay queue may be determined according to a message version number of the delayed message and a global configuration version number.

[0102] The message version number in the message configuration information is determined when the delay message is generated according to the global configuration version number in the global configuration information. For example, assuming that at 12:00 on November 26, 2024, the global configuration survival time in the global configuration information is 20 minutes, and the global configuration version number is version 1.0, at 15:00 on November 26, 2024, the global configuration survival time in the global configuration information is modified from 20 minutes to 15 minutes. At this time, the global configuration version number is version 2.0. The message version number in the message configuration information corresponding to the delay message generated during the time period from 12:00 on November 26, 2024 to 15:00 on November 26, 2024 is version 1.0. After 15:00 on November 26, 2024, the message version number in the message configuration information corresponding to the delay message generated is version 2.0.

[0103] It is understandable that after modifying and adjusting the global configuration information such as the global configuration survival time, there will be at least two delayed messages corresponding to the message version numbers in the delay queue. However, for the delayed messages in the delay queue, they can be divided into two types of delayed messages. One type is that the message version number is the same as the current global configuration version number, and the corresponding "new delayed message" indicates that the "new delayed message" is waiting for the message to be consumed according to the currently set global configuration survival time, and can also be regarded as a new delayed message that continues to enter the delay queue; the other type is that the message version number is different from the current global configuration version number, and the corresponding "old delayed message" indicates that the "old delayed message" is waiting for the message to be consumed according to the "old" global configuration survival time set before the currently set global configuration survival time. It is understandable that in order to achieve that each delayed information in the delay queue waits and is consumed according to the currently set global configuration survival time, at this time, there is no need to adjust the target survival time of the "new delayed message" in the delay queue, and only the target survival time of the "old delayed message" in the delay queue is adjusted according to the currently set global configuration survival time.

[0104] In an optional embodiment, since the message configuration information includes a message version number, and the message version number is determined based on the global configuration version number in the global configuration information corresponding to when the delayed message is generated, the message version number of each delayed message can be directly obtained from the message configuration information corresponding to each delayed message in the delay queue, and then the delayed messages to be updated in the delay queue are determined according to the message version number and the current global configuration version number. Specifically, the delayed messages corresponding to the message version numbers lower than the global configuration version numbers are taken as the delayed messages to be updated, so that the "old delayed messages" corresponding to the message version numbers in the delay queue that are different from the current global configuration version numbers are screened out, and the delayed messages to be updated are determined, and then steps 204-208 are executed.

[0105] In this embodiment, the message version number of each delayed message is obtained from the message configuration information of each delayed message in the delay queue to filter out the delayed messages to be updated whose message version number is lower than the global configuration version number. That is, the message configuration information of each delayed message in the delay queue is obtained, and it is determined whether each delayed message in the delay queue is a delayed message to be updated. By making a judgment on each delayed message in the delay queue, the purpose of accurately filtering out the delayed messages to be updated is achieved.

[0106] As an optional implementation, it is possible to determine whether the delayed message is a delayed message to be updated from the head of the delay queue to the tail of the queue, and the specific implementation steps include: obtaining the message version number in the message configuration information corresponding to the delayed message to be consumed currently from the delay queue; determining whether the message version number is less than the global configuration version number; when the message version number is less than the global configuration version number, treating the delayed message to be consumed as a delayed message to be updated, executing step 204 and / or step 206, and returning to the execution step: obtaining the message version in the message configuration information corresponding to the delayed message to be consumed currently from the delay queue; when the message version number is greater than or equal to the global configuration version number, indicating that it is a "new delayed message", and no operation is performed.

[0107] Among them, the delayed message to be consumed currently can be understood as the first delayed message in the head of the delayed queue. It should be noted that based on the processing mechanism of delayed messages in the message queue, the message queue is such as a delayed queue or a temporary delayed queue, and the remaining message survival time of each delayed message in the message queue from the head of the queue to the tail of the queue is increased in sequence, so that the processing order of delayed messages can be consistent with the order of entering the delayed queue, that is, the processing order of delayed messages in the message queue is to process delayed messages from the head of the queue to the tail of the queue in sequence, which can also be understood as the delayed message that enters the message queue first is processed first, so as to ensure the standardization of delayed message processing in the message queue.

[0108] Similarly, in this embodiment, the processing order of delayed messages in the delay queue is to process the delayed messages from the head of the queue to the tail of the queue in sequence. In order to determine the delayed message to be updated in the delay queue, the "old delayed message" is screened out from the delay queue, and the message version number in the message configuration information corresponding to the delayed message to be consumed is obtained from the delay queue, that is, the message version number corresponding to the first delayed message at the head of the queue is obtained, and the first delayed message is consumed. When the message version number is less than the global configuration version number, it indicates that the delayed message is an "old delayed message", and the delayed message is determined as a delayed message to be updated, and step 204 and / or step 206 are executed.

[0109] It is understandable that the first delayed message at the head of the queue is transferred to the temporary delay queue, and the first delayed message at the head of the queue in the delay queue has been updated. At this time, the first delayed message at the head of the queue is the second delayed message originally at the head of the queue in the delay queue. Exemplarily, taking the above Table 1 as an example, delayed message 1 in the delay queue is the first delayed message at the head of the queue, and delayed message 2 is the second delayed message at the head of the queue. After delayed message 1 is transferred from the delay queue to the temporary delay queue, the first delayed message at the head of the queue is delayed message 2. It is easy to understand that based on the processing order of delayed messages in the delay queue, each delayed message in the delay queue will eventually be at the first delayed message at the head of the queue. Therefore, it is also ensured that when the delayed message is transferred from the delay queue to the temporary delay queue, the message survival time of each delayed message from the head of the queue to the tail of the queue is increased successively, and the target survival time, that is, the remaining survival time, is increased successively.

[0110] Then, return to the execution step: obtain the message version number in the message configuration information corresponding to the delayed message to be consumed currently from the delay queue, that is, the message version number of the first delayed message at the head of the queue. At this time, the first delayed message at the head of the queue is the second delayed message originally at the head of the queue in the delay queue. Then, when it is determined that the message version number of the second delayed message is less than the global configuration version number, the delayed message to be consumed is used as the delayed message to be updated, and step 204 and / or step 206, as well as subsequent steps are executed. In this way, through the loop step: the delayed messages from the head of the queue to the tail of the delay queue are judged one by one whether the delayed messages are the delayed messages to be updated, until the message version number of the delayed message is greater than or equal to the global configuration version number.

[0111] In this embodiment, it is not necessary to obtain the message configuration information of each delayed message in the delay queue, and to determine whether each delayed message in the delay queue is a delayed message to be updated, it is only necessary to determine some of the delayed messages in the delay queue. As long as the message version number of the delayed message is greater than or equal to the global configuration version number, the delayed message and the delayed messages after it are considered to be new delayed messages, and the screening of the delayed messages to be updated is stopped at this time, thereby improving the screening efficiency and speed of the delayed messages to be updated.

[0112] It should be noted that the current global configuration version number refers to the last modification and adjustment made to the global configuration information, and the current global configuration version number can be regarded as the latest global configuration version number with the highest version number. As an example, the modified and adjusted global configuration information can be a modification of the global configuration survival time in the global configuration information. Since the global configuration version number increases by 1 each time the global configuration survival time is adjusted, it is easy to understand that for the last modification and adjustment made to the global configuration information, at this time, the value of the current global configuration version number is greater than the value of the global configuration version number that existed before the last modification and adjustment. It can be understood that the more times the global configuration information is modified, the larger the value corresponding to the global configuration version number, and the higher the version number.

[0113] For example, the initial global configuration version number is 0. After the first modification and adjustment of the global configuration survival time, the corresponding global configuration version number is 1.0. After the second modification and adjustment of the global configuration survival time, the corresponding global configuration version number is 2.0. No global configuration information is subsequently adjusted. At this time, the value corresponding to the highest global configuration version number is 2.0.

[0114] It is understandable that each delayed message to be updated can be understood as an “old delayed message” in the delay queue. The message version number is lower than the global configuration version number, which can be understood as the value corresponding to the message version number is smaller than the value corresponding to the global configuration version number.

[0115] Optionally, when the message version number is higher than or equal to the global configuration version number, it indicates that the delayed message corresponding to the message version number is the "new delayed message" in the delay queue. No processing is required for the "new delayed message", so that the "new delayed message" waits for expiration in the delay queue according to the current global configuration survival time. When the target survival time of the "new delayed message" is 0, it indicates that the "new delayed message" has reached the time limit corresponding to the global configuration survival time in the delay queue. At this time, the "new delayed message" is transferred to the dead letter queue, and then the "new delayed message" is consumed. Similarly, the message version number is higher than or equal to the global configuration version number, which can be understood as the value corresponding to the message version number is greater than or equal to the value corresponding to the global configuration version number.

[0116] In one example, after the first message consumer completes the update of the message survival time of the delayed message, it can also synchronously update the message version number of the delayed message, that is, the message version number of the delayed message can be updated to be consistent with the global configuration version number, thereby avoiding the subsequent repeated reading of the delayed message corresponding to the message version number due to the lack of synchronization between the message version number and the global configuration version number, thereby affecting the accuracy of delayed message processing.

[0117] It should be noted that when the delayed messages to be updated are determined based on the adjustment time corresponding to the global configuration information and the message generation time in the message configuration information corresponding to the delayed message, the method is similar to the method of determining the delayed messages to be updated in the delay queue based on the message version number of the delayed message and the global configuration version number, and will not be repeated here.

[0118] In an exemplary embodiment, Figure 4 As shown, by monitoring the message consumer of the dead letter queue, the target delayed message in the dead letter queue is processed, including:

[0119] Step S402, by monitoring the message consumer end of the dead letter queue, respectively obtain the message generation time of each target delayed message in the dead letter queue.

[0120] For example, the message consumer end that monitors the dead letter queue, i.e., the second message consumer end, needs to further detect whether the target delayed message is actually expired before processing each target delayed message in the dead letter queue in order to ensure the accuracy of delayed message processing. Therefore, the second message consumer end can extract the message generation time of each target delayed message from the message configuration information of each target delayed message.

[0121] Step S404, respectively obtain the time difference between the message generation time of each target delayed message and the current time, and determine the total waiting time of each target delayed message.

[0122] The total waiting time can be understood as the total survival time of the target delayed message.

[0123] Exemplarily, after obtaining the message generation time of each target delayed message, the second message consumer calculates the time difference between the message generation time and the current time, which is the total survival time of the target delayed message.

[0124] Step S406: When the total waiting time is greater than or equal to the global configuration survival time in the global configuration information, the target delay message is processed.

[0125] Exemplarily, when the total waiting time is greater than or equal to the global configuration survival time in the global configuration information, it means that the target delayed message is determined to expire, and the second message consumer can process the target delayed message. When the total waiting time is less than the global configuration survival time in the global configuration information, it means that the target delayed message has not really expired, and its waiting time needs to be recalculated and sent to the delay queue, and then processed after the message actually expires.

[0126] In this embodiment, the second message consumer end that monitors the dead letter queue obtains the message generation time of each target delayed message in the dead letter queue. The time difference between the message generation time of the target delayed message and the current time is calculated, and the time difference is the total waiting time of the target delayed message. The total waiting time is further compared with the global configuration survival time in the global configuration information. According to the comparison result between the two time lengths, it is determined whether to process the target delayed message or send the target delayed message to the delay queue to wait for actual expiration. In this way, it can be ensured that the second message consumer end processes the delayed message that is actually expired, and avoids processing the delayed message that is not actually expired, thereby ensuring the accuracy of delayed message processing.

[0127] In an exemplary embodiment, Figure 5 As shown, when the total waiting time is greater than or equal to the global configuration survival time in the global configuration information, the target delay message is processed, including:

[0128] Step S502: When the total waiting time is greater than or equal to the global configuration survival time in the global configuration information, the service state of the target service to which the target delay message belongs is obtained.

[0129] The target business may refer to the business to which the target delayed message belongs, such as an order business. The business status may refer to the current state of the target business, which may include completed and uncompleted. Taking the order business as an example, the business status may include paid and unpaid states.

[0130] Exemplarily, when the total waiting time is greater than or equal to the global configuration survival time in the global configuration information, the second message consumer needs to process the target delayed message. At this time, the second message consumer can first determine the service to which the target delayed message belongs, and then query the current status of the service to execute the corresponding message processing method.

[0131] Step S504: If the service status indicates that the target service has been completed, a message confirmation operation is performed on the target delayed message.

[0132] Step S506: If the service status indicates that the target service is not completed, after performing a service cancellation operation on the target service, a message confirmation operation on the target delay message is performed.

[0133] The message confirmation operation may refer to an operation of confirming the target delayed message, and it is understandable that after the message confirmation is completed, the message processing flow is terminated accordingly. The service cancellation operation may refer to an operation of canceling the target service.

[0134] For example, if the business status of the target business to which the target delay message belongs indicates that it has been completed, it means that there is no need to perform other processing on the target delay message, and it can be directly confirmed, thereby completing the processing flow of the target delay message. If the business status of the target business to which the target delay message belongs indicates that it has not been completed, it is necessary to cancel the business of the target business and then confirm the target delay message.

[0135] Taking the order business as an example, if the order business is in a paid state, you can directly confirm the target delay message corresponding to the order business. If the order business is in an unpaid state, cancel the order to release the commodity inventory occupied by the order, and then confirm the target delay message corresponding to the order business.

[0136] In this embodiment, when the total waiting time is greater than or equal to the global configuration survival time in the global configuration information, the business status of the target business to which the target delayed message belongs is obtained. If the business status indicates that the target business has been completed, the message confirmation operation for the target delayed message is directly performed. If the business status indicates that the target business has not been completed, the business cancellation operation is first performed on the target business, and then the message confirmation operation for the target delayed message is performed. In this way, this embodiment obtains different business states of the target business to which the target delayed message belongs, thereby determining the message processing operation corresponding to each business state, thereby effectively improving the accuracy of the message processing operation, and further improving the accuracy of the processing of delayed messages based on the message processing operation.

[0137] In an exemplary embodiment, the message transfer process also includes: for each new delayed message in the delay queue whose message version number is equal to the globally configured version number, when the actual survival time of the new delayed message reaches the globally configured survival time, the new delayed message is transferred from the delay queue to the dead letter queue.

[0138] Among them, the new delayed message refers to the delayed message that continues to enter the delay queue.

[0139] The actual survival time may refer to the time that the delayed message has been waiting in the delay queue, wherein the delayed message includes a new delayed message.

[0140] Exemplarily, for each new delayed message in the delay queue whose message version number is equal to the globally configured version number, when the actual survival time of the new delayed message reaches the globally configured survival time, that is, the actual survival time is greater than or equal to the globally configured survival time, or the target survival time of the new delayed message is less than or equal to the preset survival time, and the preset survival time is 0, it indicates that the new delayed message has expired and can be automatically transferred from the delay queue to the dead letter queue.

[0141] Based on this, in one embodiment, by monitoring the message consumer of the dead letter queue, processing the target delayed message in the dead letter queue includes: processing the new delayed message and the target delayed message in the dead letter queue through the message consumer. In this way, it can be ensured that the new delayed message and the target delayed message can be processed by the second message consumer after the message expires, thereby improving the accuracy of the entire delayed message processing.

[0142] In an exemplary embodiment, the processing of the temporary delay queue further includes: detecting whether each target delay message is transferred to the dead letter queue; and deleting the temporary delay queue when each target delay message is transferred to the dead letter queue.

[0143] For example, since the temporary delay queue is one-time, it is necessary to detect whether all target delay messages in the temporary delay queue are transferred to the dead letter queue. If all target delay messages are transferred to the dead letter queue, the temporary delay queue is deleted, and a new temporary delay queue is recreated when the configuration instruction for the message survival time is received next time. If all target delay messages are not transferred to the dead letter queue, it is necessary to wait until all target delay messages are transferred to the dead letter queue before deleting the temporary delay queue.

[0144] In this embodiment, considering that the temporary delay queue will occupy a certain amount of system memory, in this embodiment, it is detected whether each target delay message is transferred to the dead letter queue, and when each target delay message is transferred to the dead letter queue, the temporary delay queue is deleted to release the system memory, thereby reducing the memory pressure of the delayed message processing system.

[0145] In a specific embodiment, Figure 6 As shown, the delayed message processing system includes a message production end, a delay queue, a dead letter queue, a message consumption end and a global configuration module. Among them, the delay queue includes the original delay queue A and the temporary delay queue B, and the message consumption end includes a first message consumption end that monitors the delay queue A and a second message consumption end that monitors the dead letter queue. The global configuration module is used to set the global configuration information, namely the global configuration survival time and the global configuration version number.

[0146] Specifically, after the message producer generates each delayed message, the message production end will read the global configuration module to obtain the initial target survival time and message version number of each delayed message, thereby generating the message configuration information of each delayed message. The message configuration information includes the target survival time, the business ID corresponding to the delayed message, the message version number and the message generation time. Each delayed message will enter the delay queue A.

[0147] When a change occurs in the global configuration module, the first message consumer will unblock the state and obtain the message version number of each delayed message. When the message version number is lower than the global configuration version number, the waiting time of each delayed message is determined according to the global configuration survival time and the waiting time of each delayed message. The target survival time in the message configuration information corresponding to the delayed message is updated according to each waiting time to obtain the updated target delayed message, and each target delayed message is transferred from the delay queue to the temporary delay queue B.

[0148] For each target delayed message, when the target survival time of the target delayed message reaches the preset survival time, that is, when the target survival time is less than or equal to the preset survival time, the target delayed message is transferred from the temporary delay queue B to the dead letter queue. The second message consumer automatically obtains the message generation time of each target delayed message in the dead letter queue, and calculates the time difference between each message generation time and the current time as the total waiting time of each target delayed message. When the total waiting time is greater than or equal to the global configuration survival time in the global configuration information, it means that the target delayed message is determined to expire at this time, and the second message consumer can perform message processing on the target delayed message. That is, the business status of the target business to which the target delayed message belongs is obtained. If the business status of the target business indicates that it has been completed, it means that there is no need to perform other processing on the target delayed message, and it can be directly confirmed, thereby completing the processing flow of the target delayed message. If the business status of the target business indicates that it is not completed, it is necessary to cancel the business of the target business, and then confirm the target delayed message. When the total waiting time is less than the global configuration survival time in the global configuration information, it means that the target delayed message has not really expired at this time, and its waiting time needs to be recalculated.

[0149] For each new delayed message in delay queue A whose message version number is equal to the globally configured version number, when the actual survival time of the new delayed message reaches the globally configured survival time, the new delayed message is transferred from delay queue A to the dead letter queue. The second message consumer will process the new delayed messages in the dead letter queue and the target delayed messages.

[0150] When all target delayed messages are transferred to the dead letter queue, delete the temporary delay queue B, and create a new temporary delay queue the next time you receive a configuration instruction for the message survival time. If all target delayed messages are not transferred to the dead letter queue, you need to wait until all target delayed messages are transferred to the dead letter queue before deleting the temporary delay queue B.

[0151] In this embodiment, the first message consumer first obtains the global configuration information for the delayed messages in the delay queue, and then updates the message configuration information corresponding to each delayed message to be updated in the delay queue according to the global configuration information. The message configuration information includes the target survival time of the target delayed message after being updated based on the global configuration information, thereby obtaining each target delayed message, and completing the survival time adjustment of each delayed message to be updated. To adapt to the modification of the global configuration information, each delayed message in the delay queue can wait for consumption according to the survival time determined by the modified global configuration information.

[0152] It should be noted that, based on the processing mechanism of delayed messages in the message queue, such as the delayed queue or the temporary delayed queue, the remaining message survival time of each delayed message in the message queue from the head to the tail of the queue is increased successively, so that the processing order of delayed messages can be consistent with the order of entering the delay queue, that is, the processing order of delayed messages in the message queue is to process the delayed messages from the head to the tail of the queue in sequence. It can also be understood that the delayed messages that enter the message queue first are processed first, so as to ensure the standardization of delayed message processing in the message queue. In this embodiment, the message configuration information corresponding to each delayed message to be updated in the delay queue is updated according to the global configuration information. In the process of obtaining each target delayed message, the update order of the message configuration information of the delayed message by the global configuration information is also from the head of the delay queue to the tail of the delay queue, and then by transferring each target delayed message with updated message survival time from the delay queue to a newly created temporary delay queue, that is, the target delayed message obtained by updating first is first transferred and placed in the temporary delay queue. In this way, no matter in the delay queue or the temporary delay queue, the remaining message survival time of each delayed message from the head of the queue to the tail of the queue is increased successively, so that the processing order of the delayed messages is consistent with the order of entering the delay queue, ensuring the standardization of the delayed message processing. At the same time, when the global configuration information is modified, for the "old delayed message" in the delay queue that is waiting for consumption according to the survival time determined by the global configuration information before the configuration is modified, it is not necessary to resend it to the delay queue, so that the "old delayed message" can wait for consumption according to the survival time determined by the global configuration information after the configuration is modified. When the target survival time of the target delayed message updated according to the modified global configuration information reaches the preset survival time, that is, when the target survival time is less than or equal to the preset survival time, it means that the target delayed message has expired, and the message queue processing mechanism will automatically transfer the target delayed message from the delayed temporary queue to the dead letter queue, and the second message consumer that monitors the dead letter queue will process the target delayed message. The entire solution overcomes the technical defect that the current message queue cannot flexibly configure and change the expiration time of the delayed message, which makes the current delayed message processing difficult to adapt to various business scenarios.

[0153] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0154] Based on the same inventive concept, the embodiment of the present application also provides a delayed message processing device for implementing the delayed message processing method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in the embodiments of one or more delayed message processing devices provided below can refer to the limitations of the delayed message processing method above, and will not be repeated here.

[0155] In an exemplary embodiment, Figure 7 As shown, a delayed message processing device is provided, which is applied to a first message consumer end that monitors a delayed queue, and includes: a global configuration module 702, which is used to obtain global configuration information for delayed messages; a message configuration update module 704, which is used to update the message configuration information corresponding to each delayed message to be updated in the delay queue according to the global configuration information, and obtain each target delayed message, wherein the message configuration information includes the target survival time of the target delayed message after being updated based on the global configuration information; a first transfer module 706, which is used to transfer each target delayed message from the delay queue to a temporary delay queue; a second transfer module 708, which is used to transfer the target delayed message from the temporary delay queue to the dead letter queue for each target delayed message when the target survival time of the target delayed message reaches a preset survival time, so as to process the target delayed message in the dead letter queue by the message consumer end that monitors the dead letter queue.

[0156] In one of the embodiments, the global configuration information includes the global configuration survival time and / or the global configuration version number; the message configuration update module 704 is also used in one of the following methods: Method 1: When the global configuration information includes the global configuration survival time, each delayed message waiting in the delay queue is used as a delayed message to be updated, and the message configuration information corresponding to each delayed message to be updated is updated according to the global configuration survival time to obtain each target delayed message; or, according to the adjustment time corresponding to the global configuration information and the message generation time in the message configuration information corresponding to the delayed message, the delayed messages to be updated in the delay queue are determined, and the message configuration information corresponding to each delayed message to be updated is updated according to the global configuration survival time to obtain each target delayed message; Method 2 : When the global configuration information includes the global configuration version number, the various delayed messages to be updated in the delay queue are determined according to the global configuration version number and the message version number of the delayed message, the global configuration survival time associated with the global configuration version number is obtained, and the message configuration information corresponding to the various delayed messages to be updated is updated according to the global configuration survival time to obtain each target delayed message; Method three: When the global configuration information includes the global configuration survival time and the global configuration version number, the various delayed messages to be updated in the delay queue are determined according to the global configuration version number and the message version number of the delayed message, and the message configuration information corresponding to the various delayed messages to be updated is updated according to the global configuration survival time to obtain each target delayed message; wherein the message configuration information includes the message generation time and the message version number.

[0157] In one of the embodiments, the message configuration update module 704 is also used to: determine the waiting time of each delayed message based on the globally configured survival time and the waiting time of each delayed message; update the target survival time in the message configuration information corresponding to the delayed message according to each waiting time to obtain each target delayed message; wherein the waiting time of each delayed message is determined based on the message generation time and the current time in the message configuration information of each delayed message in the delay queue.

[0158] In one of the embodiments, the second transfer module 708 is also used to: obtain the message generation time of each target delayed message in the dead letter queue by monitoring the message consumer end of the dead letter queue; obtain the time difference between the message generation time of each target delayed message and the current time, and determine the total waiting time of each target delayed message; when the total waiting time is greater than or equal to the global configuration survival time in the global configuration information, process the target delayed message.

[0159] In one of the embodiments, the second transfer module 708 is also used to: when the total waiting time is greater than or equal to the global configuration survival time in the global configuration information, obtain the business status of the target business to which the target delayed message belongs; if the business status indicates that the target business has been completed, execute a message confirmation operation for the target delayed message; if the business status indicates that the target business has not been completed, after performing a business cancellation operation on the target business, execute a message confirmation operation for the target delayed message.

[0160] In one of the embodiments, the device is also used to: for each new delayed message in the delay queue whose message version number is equal to the globally configured version number, when the actual survival time of the new delayed message reaches the globally configured survival time, transfer the new delayed message from the delay queue to the dead letter queue; the second transfer module 708 is also used to: process the new delayed messages and the target delayed messages in the dead letter queue by monitoring the message consumer end of the dead letter queue.

[0161] In one of the embodiments, the device is also used to: determine the configuration type corresponding to the global configuration information; when the configuration type is the first configuration type, execute the step of updating the message configuration information corresponding to each delayed message to be updated in the delay queue according to the global configuration information to obtain each target delayed message; when the configuration type is the second configuration type, use each delayed message to be updated as each target delayed message, transfer each target delayed message from the delay queue to a temporary delay queue, and for each target delayed message, when the target survival time of the target delayed message reaches the preset target survival time, transfer the target delayed message from the temporary delay queue to the dead letter queue, so as to process the target delayed message in the dead letter queue by monitoring the message consumer end of the dead letter queue.

[0162] Each module in the above-mentioned delayed message processing device can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above-mentioned modules can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each of the above modules.

[0163] In an exemplary embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as shown in FIG. Figure 8As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store processing data of delayed messages. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method for processing delayed messages is implemented.

[0164] Those skilled in the art will understand that Figure 8 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0165] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the following steps when executing the computer program: obtaining global configuration information for delayed messages; updating message configuration information corresponding to each delayed message to be updated in a delay queue according to the global configuration information, and obtaining each target delayed message, wherein the message configuration information includes a target survival time of the target delayed message after being updated based on the global configuration information; transferring each target delayed message from the delay queue to a temporary delay queue; for each target delayed message, when the target survival time of the target delayed message reaches a preset survival time, transferring the target delayed message from the temporary delay queue to a dead letter queue, so as to process the target delayed message in the dead letter queue by monitoring the message consumer end of the dead letter queue.

[0166] In one embodiment, the processor further implements the following steps when executing the computer program: Method 1: When the global configuration information includes the global configuration survival time, each delayed message waiting in the delay queue is used as a delayed message to be updated, and the message configuration information corresponding to each delayed message to be updated is updated according to the global configuration survival time to obtain each target delayed message; or, according to the adjustment time corresponding to the global configuration information and the message generation time in the message configuration information corresponding to the delayed message, each delayed message to be updated in the delay queue is determined, and the message configuration information corresponding to each delayed message to be updated is updated according to the global configuration survival time to obtain each target delayed message; Method 2: When the global configuration information includes the global configuration version number Method three: when the global configuration information includes the global configuration survival time and the global configuration version number, determine the various delayed messages to be updated in the delay queue according to the global configuration version number and the message version number of the delayed message, obtain the global configuration survival time associated with the global configuration version number, update the message configuration information corresponding to the various delayed messages to be updated according to the global configuration survival time, and obtain each target delayed message; wherein, the message configuration information includes the message generation time and the message version number.

[0167] In one embodiment, the processor also implements the following steps when executing the computer program: determining the waiting time of each delayed message based on the globally configured survival time and the waiting time of each delayed message; updating the target survival time in the message configuration information corresponding to the delayed message according to each waiting time to obtain each target delayed message; wherein the waiting time of each delayed message is determined based on the message generation time and the current time in the message configuration information of each delayed message in the delay queue.

[0168] In one embodiment, the processor also implements the following steps when executing the computer program: by monitoring the message consumer end of the dead letter queue, respectively obtain the message generation time of each target delayed message in the dead letter queue; respectively obtain the time difference between the message generation time of each target delayed message and the current time, and determine the total waiting time of each target delayed message; when the total waiting time is greater than or equal to the global configuration survival time in the global configuration information, process the target delayed message.

[0169] In one embodiment, when the processor executes the computer program, the following steps are also implemented: when the total waiting time is greater than or equal to the global configuration survival time in the global configuration information, the business status of the target business to which the target delayed message belongs is obtained; if the business status indicates that the target business has been completed, a message confirmation operation is performed for the target delayed message; if the business status indicates that the target business has not been completed, after performing a business cancellation operation on the target business, a message confirmation operation is performed for the target delayed message.

[0170] In one embodiment, the processor also implements the following steps when executing the computer program: for each new delayed message in the delay queue whose message version number is equal to the globally configured version number, when the actual survival time of the new delayed message reaches the globally configured survival time, the new delayed message is transferred from the delay queue to the dead letter queue; by monitoring the message consumer end of the dead letter queue, the target delayed message in the dead letter queue is processed, including: by monitoring the message consumer end of the dead letter queue, the new delayed message and the target delayed message in the dead letter queue are processed.

[0171] In one embodiment, when the processor executes the computer program, the following steps are also implemented: determining the configuration type corresponding to the global configuration information; when the configuration type is the first configuration type, executing the step of updating the message configuration information corresponding to each delayed message to be updated in the delay queue according to the global configuration information to obtain each target delayed message; when the configuration type is the second configuration type, taking each delayed message to be updated as each target delayed message, transferring each target delayed message from the delay queue to the temporary delay queue, and for each target delayed message, when the target survival time of the target delayed message reaches the preset target survival time, transferring the target delayed message from the temporary delay queue to the dead letter queue, so as to process the target delayed message in the dead letter queue by monitoring the message consumer end of the dead letter queue.

[0172] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented: obtaining global configuration information for delayed messages; updating message configuration information corresponding to each delayed message to be updated in a delay queue according to the global configuration information, and obtaining each target delayed message, wherein the message configuration information includes a target survival time of the target delayed message after being updated based on the global configuration information; transferring each target delayed message from the delay queue to a temporary delay queue; for each target delayed message, when the target survival time of the target delayed message reaches a preset survival time, transferring the target delayed message from the temporary delay queue to a dead letter queue, so as to process the target delayed message in the dead letter queue by monitoring the message consumer end of the dead letter queue.

[0173] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: Method 1: When the global configuration information includes the global configuration survival time, each delayed message waiting in the delay queue is used as a delayed message to be updated, and the message configuration information corresponding to each delayed message to be updated is updated according to the global configuration survival time to obtain each target delayed message; or, according to the adjustment time corresponding to the global configuration information and the message generation time in the message configuration information corresponding to the delayed message, each delayed message to be updated in the delay queue is determined, and the message configuration information corresponding to each delayed message to be updated is updated according to the global configuration survival time to obtain each target delayed message; Method 2: When the global configuration information includes the global configuration version Method three: when the global configuration information includes the global configuration survival time and the global configuration version number, determine the various delayed messages to be updated in the delay queue according to the global configuration version number and the message version number of the delayed message, obtain the global configuration survival time associated with the global configuration version number, update the message configuration information corresponding to the various delayed messages to be updated according to the global configuration survival time, and obtain each target delayed message; Method three: when the global configuration information includes the global configuration survival time and the global configuration version number, determine the various delayed messages to be updated in the delay queue according to the global configuration version number and the message version number of the delayed message, update the message configuration information corresponding to the various delayed messages to be updated according to the global configuration survival time, and obtain each target delayed message; wherein the message configuration information includes the message generation time and the message version number.

[0174] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: based on the globally configured survival time and the waiting time of each delayed message, the waiting time of each delayed message is determined; based on each waiting time, the target survival time in the message configuration information corresponding to the delayed message is updated to obtain each target delayed message; wherein, the waiting time of each delayed message is determined based on the message generation time and the current time in the message configuration information of each delayed message in the delay queue.

[0175] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: by monitoring the message consumer end of the dead letter queue, the message generation time of each target delayed message in the dead letter queue is obtained respectively; the time difference between the message generation time of each target delayed message and the current time is obtained respectively, and the total waiting time of each target delayed message is determined; when the total waiting time is greater than or equal to the global configuration survival time in the global configuration information, the target delayed message is processed.

[0176] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: when the total waiting time is greater than or equal to the global configuration survival time in the global configuration information, the business status of the target business to which the target delayed message belongs is obtained; if the business status indicates that the target business has been completed, a message confirmation operation is performed for the target delayed message; if the business status indicates that the target business has not been completed, after performing a business cancellation operation on the target business, a message confirmation operation is performed for the target delayed message.

[0177] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: for each new delayed message in the delay queue whose message version number is equal to the globally configured version number, when the actual survival time of the new delayed message reaches the globally configured survival time, the new delayed message is transferred from the delay queue to the dead letter queue; by monitoring the message consumer end of the dead letter queue, the target delayed message in the dead letter queue is processed, including: by monitoring the message consumer end of the dead letter queue, the new delayed message and the target delayed message in the dead letter queue are processed.

[0178] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: determining the configuration type corresponding to the global configuration information; when the configuration type is the first configuration type, executing the step of updating the message configuration information corresponding to each delayed message to be updated in the delay queue according to the global configuration information to obtain each target delayed message; when the configuration type is the second configuration type, treating each delayed message to be updated as each target delayed message, transferring each target delayed message from the delay queue to the temporary delay queue, and for each target delayed message, when the target survival time of the target delayed message reaches the preset target survival time, transferring the target delayed message from the temporary delay queue to the dead letter queue, so as to process the target delayed message in the dead letter queue by monitoring the message consumer end of the dead letter queue.

[0179] In one embodiment, a computer program product is provided, including a computer program, which implements the following steps when executed by a processor: obtaining global configuration information for delayed messages; updating, through a first message consumer, message configuration information corresponding to each delayed message to be updated in a delay queue according to the global configuration information, to obtain each target delayed message, wherein the message configuration information includes a target survival time of the target delayed message after being updated based on the global configuration information; transferring each target delayed message from the delay queue to a temporary delay queue; for each target delayed message, when the target survival time of the target delayed message reaches a preset survival time, transferring the target delayed message from the temporary delay queue to a dead letter queue, so as to process the target delayed message in the dead letter queue by monitoring the message consumer of the dead letter queue.

[0180] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: Method 1: When the global configuration information includes the global configuration survival time, each delayed message waiting in the delay queue is used as a delayed message to be updated, and the message configuration information corresponding to each delayed message to be updated is updated according to the global configuration survival time to obtain each target delayed message; or, according to the adjustment time corresponding to the global configuration information and the message generation time in the message configuration information corresponding to the delayed message, each delayed message to be updated in the delay queue is determined, and the message configuration information corresponding to each delayed message to be updated is updated according to the global configuration survival time to obtain each target delayed message; Method 2: When the global configuration information includes the global configuration version Method three: when the global configuration information includes the global configuration survival time and the global configuration version number, determine the various delayed messages to be updated in the delay queue according to the global configuration version number and the message version number of the delayed message, obtain the global configuration survival time associated with the global configuration version number, update the message configuration information corresponding to the various delayed messages to be updated according to the global configuration survival time, and obtain each target delayed message; Method three: when the global configuration information includes the global configuration survival time and the global configuration version number, determine the various delayed messages to be updated in the delay queue according to the global configuration version number and the message version number of the delayed message, update the message configuration information corresponding to the various delayed messages to be updated according to the global configuration survival time, and obtain each target delayed message; wherein the message configuration information includes the message generation time and the message version number.

[0181] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: based on the globally configured survival time and the waiting time of each delayed message, the waiting time of each delayed message is determined; based on each waiting time, the target survival time in the message configuration information corresponding to the delayed message is updated to obtain each target delayed message; wherein, the waiting time of each delayed message is determined based on the message generation time and the current time in the message configuration information of each delayed message in the delay queue.

[0182] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: by monitoring the message consumer end of the dead letter queue, the message generation time of each target delayed message in the dead letter queue is obtained respectively; the time difference between the message generation time of each target delayed message and the current time is obtained respectively, and the total waiting time of each target delayed message is determined; when the total waiting time is greater than or equal to the global configuration survival time in the global configuration information, the target delayed message is processed.

[0183] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: when the total waiting time is greater than or equal to the global configuration survival time in the global configuration information, the business status of the target business to which the target delayed message belongs is obtained; if the business status indicates that the target business has been completed, a message confirmation operation is performed for the target delayed message; if the business status indicates that the target business has not been completed, after performing a business cancellation operation on the target business, a message confirmation operation is performed for the target delayed message.

[0184] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: for each new delayed message in the delay queue whose message version number is equal to the globally configured version number, when the actual survival time of the new delayed message reaches the globally configured survival time, the new delayed message is transferred from the delay queue to the dead letter queue; by monitoring the message consumer end of the dead letter queue, the target delayed message in the dead letter queue is processed, including: by monitoring the message consumer end of the dead letter queue, the new delayed message and the target delayed message in the dead letter queue are processed.

[0185] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: determining the configuration type corresponding to the global configuration information; when the configuration type is the first configuration type, executing the step of updating the message configuration information corresponding to each delayed message to be updated in the delay queue according to the global configuration information to obtain each target delayed message; when the configuration type is the second configuration type, treating each delayed message to be updated as each target delayed message, transferring each target delayed message from the delay queue to the temporary delay queue, and for each target delayed message, when the target survival time of the target delayed message reaches the preset target survival time, transferring the target delayed message from the temporary delay queue to the dead letter queue, so as to process the target delayed message in the dead letter queue by monitoring the message consumer end of the dead letter queue.

[0186] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.

[0187] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.

[0188] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0189] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A method for processing delayed messages, characterized in that: The method comprises: Get global configuration information for delayed messages; Update the message configuration information corresponding to each delayed message to be updated in the delay queue according to the global configuration information to obtain each target delayed message, wherein the message configuration information includes the target survival time of the target delayed message after being updated based on the global configuration information; Transferring each of the target delayed messages from the delay queue to a temporary delay queue; For each of the target delayed messages, when the target survival time of the target delayed message reaches the preset survival time, the target delayed message is transferred from the temporary delay queue to the dead letter queue, so as to process the target delayed message in the dead letter queue by monitoring the message consumer end of the dead letter queue.

2. The method according to claim 1, characterized in that The global configuration information includes a global configuration survival time and / or a global configuration version number; the message configuration information corresponding to each delayed message to be updated in the delay queue is updated according to the global configuration information to obtain each target delayed message, including one of the following methods: Method 1: When the global configuration information includes the global configuration survival time, each delayed message waiting in the delay queue is used as a delayed message to be updated, and the message configuration information corresponding to each delayed message to be updated is updated according to the global configuration survival time to obtain each target delayed message; or, according to the adjustment time corresponding to the global configuration information and the message generation time in the message configuration information corresponding to the delayed message, each delayed message to be updated in the delay queue is determined, and the message configuration information corresponding to each delayed message to be updated is updated according to the global configuration survival time to obtain each target delayed message; Method 2: When the global configuration information includes a global configuration version number, determine each delayed message to be updated in the delay queue according to the global configuration version number and the message version number of the delayed message, obtain the global configuration survival time associated with the global configuration version number, and update the message configuration information corresponding to each delayed message to be updated according to the global configuration survival time to obtain each target delayed message; Method 3: When the global configuration information includes the global configuration survival time and the global configuration version number, each delayed message to be updated in the delay queue is determined according to the global configuration version number and the message version number of the delayed message, and the message configuration information corresponding to each delayed message to be updated is updated according to the global configuration survival time to obtain each target delayed message; The message configuration information includes the message generation time and the message version number.

3. The method according to claim 2, characterized in that The updating of the message configuration information corresponding to each of the delayed messages to be updated according to the global configuration survival time to obtain each target delayed message includes: Determine the waiting time of each delayed message according to the global configuration survival time and the waiting time of each delayed message; According to each of the waiting time periods, the target survival time in the message configuration information corresponding to the delay message is updated to obtain each target delay message; The waiting time of each delayed message is determined according to the message generation time and the current time in the message configuration information of each delayed message in the delay queue.

4. The method according to any one of claims 1 to 3, characterized in that: The processing of the target delayed message in the dead letter queue by monitoring the message consumer end of the dead letter queue includes: By monitoring the message consumer end of the dead letter queue, respectively obtaining the message generation time of each of the target delayed messages in the dead letter queue; Respectively obtain the time difference between the message generation time of each target delayed message and the current time, and determine the total waiting time of each target delayed message; When the total waiting time is greater than or equal to the global configuration survival time in the global configuration information, the target delay message is processed.

5. The method according to claim 4, characterized in that When the total waiting time is greater than or equal to the global configuration survival time in the global configuration information, processing the target delay message includes: When the total waiting time is greater than or equal to the global configuration survival time in the global configuration information, obtaining the service state of the target service to which the target delay message belongs; If the service status indicates that the target service has been completed, performing a message confirmation operation for the target delay message; If the service status indicates that the target service is not completed, after performing a service cancellation operation on the target service, a message confirmation operation on the target delay message is performed.

6. The method according to claim 1, characterized in that The global configuration information includes the global configuration survival time and the global configuration version number; the method further includes: For each new delayed message in the delay queue whose message version number is equal to the global configuration version number, when the actual survival time of the new delayed message reaches the global configuration survival time, the new delayed message is transferred from the delay queue to the dead letter queue; The processing of the target delayed message in the dead letter queue by monitoring the message consumer end of the dead letter queue includes: The new delayed message and the target delayed message in the dead letter queue are processed by monitoring the message consumer end of the dead letter queue.

7. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: Determine the configuration type corresponding to the global configuration information; When the configuration type is the first configuration type, executing the step of updating the message configuration information corresponding to each delayed message to be updated in the delay queue according to the global configuration information to obtain each target delayed message; When the configuration type is the second configuration type, each delayed message to be updated is used as a target delayed message, and each target delayed message is transferred from the delay queue to the temporary delay queue. For each target delayed message, when the target survival time of the target delayed message reaches the preset survival time, the target delayed message is transferred from the temporary delay queue to the dead letter queue, so as to process the target delayed message in the dead letter queue by monitoring the message consumer end of the dead letter queue.

8. A delayed message processing device, characterized in that: The device comprises: The global configuration module is used to obtain the global configuration information for delayed messages; A message configuration updating module, used to update the message configuration information corresponding to each delayed message to be updated in the delay queue according to the global configuration information, and obtain each target delayed message, wherein the message configuration information includes the target survival time of the target delayed message after being updated based on the global configuration information; A first transfer module, configured to transfer each of the target delayed messages from the delay queue to a temporary delay queue; The second transfer module is used to transfer each target delayed message from the temporary delay queue to the dead letter queue when the target survival time of the target delayed message reaches a preset survival time, so as to process the target delayed message in the dead letter queue by monitoring the message consumer end of the dead letter queue.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.