Message processing methods, apparatus, devices and storage media

By generating identifiers for target messages in the microservice architecture and caching their corresponding relationships, and setting up a compensation mechanism, the problem of consumer task execution failure was solved, the task execution success rate was improved, and the user experience was enhanced.

CN115757494BActive Publication Date: 2026-05-26AGRICULTURAL BANK OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
AGRICULTURAL BANK OF CHINA
Filing Date
2022-11-18
Publication Date
2026-05-26

AI Technical Summary

Technical Problem

In a microservices architecture, consumers often fail when performing and retrieving tasks, impacting the user experience.

Method used

By generating identifiers for target messages and caching their correspondence with target messages in historical message records, a compensation mechanism is set up so that consumers can re-acquire and execute tasks when task execution fails.

Benefits of technology

It increases the success rate of task execution and improves the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115757494B_ABST
    Figure CN115757494B_ABST
Patent Text Reader

Abstract

This application discloses a message processing method, apparatus, device, and storage medium, relating to the field of computer technology. It can increase the number of times a consumer can execute the same task, thereby increasing the probability of successful task execution and improving the user experience. The method includes: upon receiving a first read instruction from a target consumer, determining a target message from a message queue based on the first read instruction; generating an identifier for the target message and caching the correspondence between the target message and the identifier in a historical message record; returning first read information to the target consumer; the first read information includes the identifier and the target message, used to instruct the target consumer to read and execute the message content in the target message, and in the event of execution failure, initiating a second read instruction; the second read instruction, carrying at least the identifier, is used to re-acquire the target message, and read and execute it.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a message processing method, apparatus, device, and storage medium. Background Technology

[0002] Microservice architecture is a commonly used distributed architecture. It can be broken down into multiple relatively independent services that can interact with each other using lightweight communication mechanisms. Currently, in microservice architectures, producers and consumers do not communicate directly. After producing messages, the producer stores them in a remote dictionary server (Redis) database as a message queue. Consumers do not retrieve messages from the producer but instead retrieve them sequentially from the message queue.

[0003] However, in the existing microservice architecture, there are frequent instances where consumers fail to execute tasks corresponding to the messages they receive, which affects the user experience. Summary of the Invention

[0004] This application provides a message processing method, apparatus, device, and storage medium that can increase the number of times a consumer can execute the same task, thereby increasing the probability of successful task execution and improving the user experience.

[0005] To achieve the above objectives, this application adopts the following technical solution:

[0006] In a first aspect, this application provides a message processing method, comprising: upon receiving a first read instruction from a target consumer, determining a target message from a message queue based on the first read instruction; generating an identifier for the target message and caching the correspondence between the target message and the identifier in a historical message record; returning first read information to the target consumer; the first read information includes the identifier and the target message, used to instruct the target consumer to read and execute the message content in the target message, and initiating a second read instruction if execution fails; the second read instruction carries at least the identifier, used to re-acquire the target message, and read and execute it.

[0007] In the technical solution provided in this application, upon receiving the first read instruction from the target consumer, the determined target message is not directly returned to the target consumer. Instead, an identifier for the target message is generated first, and the correspondence between the target message and the identifier is cached in the historical message record. Then, the first read information containing the identifier and the target message is returned to the target consumer. Thus, if the target consumer fails to read and execute the message content of the target message for the first time, it can re-initiate a second read instruction based on the identifier in the first read information to retrieve, read, and execute the target message again. It can be seen that this application sets up a compensation mechanism for the target consumer's task execution process. By generating an identifier for the target message and storing the correspondence between the target message and the identifier in the historical message record, the target consumer can easily retrieve the target message and execute the task again when the task execution fails. This increases the number of times the consumer can execute the same task, thereby increasing the probability of successful task execution and improving the user experience.

[0008] Optionally, in one possible design approach, after the above-mentioned "returning the first read information to the target consumer", it may also include:

[0009] Upon receiving a second read instruction from the target consumer, the target message is retrieved from the historical message record based on the identifier;

[0010] Return a second read message to the target consumer; the second read message contains at least the target message, which instructs the target consumer to read and execute the message content in the target message again.

[0011] Optionally, in another possible design, the second read information is also used to instruct the target consumer to return failure feedback information in the event of a second execution failure; after the above-mentioned "returning the second read information to the target consumer", it may also include:

[0012] Upon receiving a failure feedback message from the target consumer, the corresponding target message is retrieved from the historical message record based on the identifier carried in the failure feedback message.

[0013] Return the target message to the target producer corresponding to the target message, instructing the target producer to perform a rollback operation on the target message.

[0014] Optionally, in another possible design approach, the identifier includes a flag bit used to characterize the number of times the target message has been executed, and the initial value of the flag bit is a preset value; the aforementioned "finding the target message from historical message records based on the identifier" may include:

[0015] Determine whether the flag bit meets the preset conditions; if the flag bit meets the preset conditions, search for the target message from the historical message record based on the identifier;

[0016] Returning second read information to the target consumer includes: updating the flag bit, updating the identifier in the historical message record according to the updated flag bit, and returning second read information to the target consumer; the second read information also includes the updated identifier, and is also used to instruct the target consumer to re-initiate the second read instruction in the event of execution failure.

[0017] Optionally, in another possible design approach, after determining whether the flag bit meets the preset conditions, it may also include:

[0018] If the flag does not meet the preset conditions, the target message is returned to the target producer corresponding to the target message to instruct the target producer to perform a rollback operation on the target message.

[0019] Optionally, in another possible design approach, after returning the target message to the target producer corresponding to the target message, the message processing method provided in this application may further include:

[0020] Delete the mapping between target messages and identifiers cached in the historical message record.

[0021] Optionally, in another possible design, the identifier also includes the execution status of the target message; the first read information is also used to instruct the target consumer to return success feedback information if the execution is successful; the message processing method provided in this application may also include:

[0022] Update the execution status upon receiving a success feedback message from the target consumer.

[0023] Secondly, this application provides a message processing apparatus, including: a determination module, a cache module, and a return module;

[0024] The determination module is used to determine the target message from the message queue based on the first read instruction received from the target consumer.

[0025] The caching module is used to generate identifiers for target messages and cache the correspondence between target messages and identifiers in the historical message record.

[0026] The return module is used to return the first read information to the target consumer. The first read information contains an identifier and a target message, which is used to instruct the target consumer to read and execute the message content in the target message, and to initiate a second read instruction if the execution fails. The second read instruction carries at least an identifier and is used to retrieve the target message again, and to read and execute it.

[0027] Optionally, in one possible design, the message processing apparatus provided in this application may further include: a lookup module;

[0028] The lookup module is used to search for the target message from the historical message record based on the identifier after the return module returns the first read information to the target consumer and receives the second read instruction from the target consumer.

[0029] The return module is also used to return a second read information to the target consumer; the second read information contains at least the target message, which instructs the target consumer to read and execute the message content in the target message again.

[0030] Optionally, in another possible design approach, the second read information is also used to instruct the target consumer to return failure feedback information in the event of a second execution failure;

[0031] The lookup module is also used to look up the corresponding target message from the historical message record based on the identifier carried in the failure feedback information after the return module returns the second read information to the target consumer and receives the failure feedback information returned by the target consumer.

[0032] The return module is also used to return the target message to the target producer corresponding to the target message, instructing the target producer to perform a rollback operation on the target message.

[0033] Optionally, in another possible design approach, the identifier includes a flag bit that represents the number of times the target message is executed, and the initial value of the flag bit is a preset value.

[0034] The search module is specifically used to: determine whether the flag bit meets the preset conditions; and if the flag bit meets the preset conditions, search for the target message from the historical message record based on the identifier.

[0035] The return module is specifically used to: update the flag bit, update the identifier in the historical message record according to the updated flag bit, and return the second read information to the target consumer; the second read information also includes the updated identifier, and is also used to instruct the target consumer to initiate the second read command again in the event of execution failure.

[0036] Optionally, in another possible design approach, the return module is also used for:

[0037] After the lookup module determines whether the flag meets the preset conditions, if it determines that the flag does not meet the preset conditions, it returns the target message to the target producer corresponding to the target message, instructing the target producer to perform a rollback operation on the target message.

[0038] Optionally, in another possible design, the message processing apparatus provided in this application may also include a deletion module;

[0039] The deletion module is used to delete the mapping between the target message and the identifier cached in the historical message record after the return module returns the target message to the target producer corresponding to the target message.

[0040] Optionally, in another possible design, the identifier also includes the execution status of the target message; the first read information is also used to instruct the target consumer to return success feedback information if the execution is successful; the message processing apparatus provided in this application may also include an update module;

[0041] The update module is used to update the execution status upon receiving a success feedback message from the target consumer.

[0042] Thirdly, this application provides a message processing device, including a memory, a processor, a bus, and a communication interface; the memory is used to store computer execution instructions, and the processor is connected to the memory via the bus; when the message processing device is running, the processor executes the computer execution instructions stored in the memory, so that the message processing device performs the message processing method as provided in the first aspect above.

[0043] Fourthly, this application provides a computer-readable storage medium storing instructions that, when executed by a computer, cause the computer to perform the message processing method provided in the first aspect.

[0044] Fifthly, this application provides a computer program product including computer instructions that, when executed on a computer, cause the computer to perform the message processing method as provided in the first aspect.

[0045] It should be noted that the aforementioned computer instructions may be stored, in whole or in part, on a computer-readable storage medium. This computer-readable storage medium may be packaged together with the processor of the message processing device, or it may be packaged separately from the processor of the message processing device; this application does not impose any limitations on this.

[0046] The descriptions of the second, third, fourth, and fifth aspects in this application can be referenced to the detailed description of the first aspect; and the beneficial effects of the descriptions of the second, third, fourth, and fifth aspects can be referenced to the analysis of the beneficial effects of the first aspect, which will not be repeated here.

[0047] In this application, the names of the aforementioned devices or functional modules are not limited, and in actual implementation, these devices or functional modules may appear under other names. As long as the function of each device or functional module is similar to that of this application, they all fall within the scope of the claims of this application and their equivalents.

[0048] These or other aspects of this application will become more readily apparent in the following description. Attached Figure Description

[0049] Figure 1 A flowchart illustrating a message processing method provided in an embodiment of this application;

[0050] Figure 2 This application provides a schematic diagram of a message queue arrangement as an embodiment of the present application.

[0051] Figure 3 A flowchart illustrating another message processing method provided in an embodiment of this application;

[0052] Figure 4 A flowchart illustrating another message processing method provided in an embodiment of this application;

[0053] Figure 5 This is a schematic diagram of the structure of a message processing device provided in an embodiment of this application;

[0054] Figure 6 This is a schematic diagram of the structure of a message processing device provided in an embodiment of this application. Detailed Implementation

[0055] The message processing method, apparatus, device, and storage medium provided in the embodiments of this application will now be described in detail with reference to the accompanying drawings.

[0056] In this article, the term "and / or" is merely a description of the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can represent three situations: A exists alone, A and B exist simultaneously, and B exists alone.

[0057] The terms "first" and "second," etc., used in the specification and drawings of this application are used to distinguish different objects or to distinguish different treatments of the same object, rather than to describe a specific order of objects.

[0058] Furthermore, the terms "comprising" and "having," and any variations thereof, used in the description of this application are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the steps or units listed, but may optionally include other steps or units not listed, or may optionally include other steps or units inherent to such process, method, product, or apparatus.

[0059] It should be noted that in the embodiments of this application, the words "exemplary" or "for example" are used to indicate examples, illustrations, or explanations. Any embodiment or design scheme described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design schemes. Specifically, the use of the words "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.

[0060] In the description of this application, unless otherwise stated, "a plurality of" means two or more.

[0061] Furthermore, the acquisition, storage, use, and processing of data in this application's technical solution all comply with relevant national laws and regulations.

[0062] In existing microservice architectures, producers and consumers do not communicate directly. After producing messages, producers can store them in a Redis database as a message queue. Consumers do not retrieve messages from the producer but instead retrieve them sequentially from the message queue. However, in existing microservice architectures, there are frequent instances where consumers encounter task failures when executing tasks corresponding to the retrieved messages, impacting the user experience.

[0063] To address the problems existing in the prior art, this application provides a message processing method. This method sets up a compensation mechanism for the task execution process of the target consumer. By generating an identifier for the target message and storing the correspondence between the target message and the identifier in the historical message record, the target consumer can easily retrieve the target message and execute the task again when the task execution fails. This can increase the number of times the consumer executes the same task, thereby increasing the probability of successful task execution and improving the user experience.

[0064] The message processing method provided in this application embodiment can be executed by the message processing device provided in this application embodiment. This device can be implemented in software and / or hardware and integrated into the message processing device executing the method. For example, the message processing device in this application embodiment can be a Redis database server or server cluster (hereinafter referred to as Redis in the description of this application embodiment).

[0065] The message processing method provided in the embodiments of this application will be described below with reference to the accompanying drawings.

[0066] Reference Figure 1 The message processing method provided in this application includes S101-S103:

[0067] S101. Upon receiving the first read instruction from the target consumer, determine the target message from the message queue based on the first read instruction.

[0068] The first read instruction is a message read instruction initiated by the target consumer.

[0069] The message processing method provided in this application embodiment can be applied to a message processing system that includes Redis, multiple consumers, and multiple producers. Redis contains multiple message queues; different producers can add their produced messages to different message queues, and consumers can retrieve target messages from the message queues based on a first read command.

[0070] Optionally, in this embodiment, multiple different consumers can retrieve target messages from the same message queue, thus meeting the business requirements of multicast scenarios. For example, when a payment transaction is generated in the server system corresponding to a producer, the payment transaction needs to be logged through the client system corresponding to consumer A, and a message notification needs to be sent to the user through the client system corresponding to another consumer B. In this case, after generating the payment transaction, the producer can initiate an asynchronous thread to add the payment transaction message to the corresponding message queue. Consumer A can retrieve the payment transaction message from the message queue and perform the logging task, while consumer B can retrieve the payment transaction message from the message queue and perform the message notification task.

[0071] In addition, to help Redis clearly identify the target of the first read command and thus accurately return the target message to the corresponding target consumer, the first read command can carry the identifier of the target consumer.

[0072] Reference Figure 2 This application also provides a schematic diagram of message queue arrangement in its embodiments. For example... Figure 2As shown, the message queue contains multiple messages generated by the producer, such as message 1, message 2, message 3, message 4, message 5, message 6, and message 7. These messages are inserted into the message queue sequentially according to their generation order, and Redis can automatically generate unique message numbers for these messages. For example, the message number can be a timestamp sequence. For instance, the message number could be 1624346990322-2, indicating that the message was generated at the millisecond timestamp of 1624346990322, and is the second message generated within that millisecond. When Redis generates message numbers, the later generated message number must be greater than the previously generated message number.

[0073] The first read command can also include the message number of the message obtained after the target consumer last initiated the first read command. This allows Redis to determine which message the target consumer last processed based on the message number in the first read command, thus identifying the target message to be processed. For example, the message number in the first read command might be... Figure 2 If Redis knows the message number of message 3, it can determine that message 3 has already been read. The target message to be processed now should be message 4. In other words, message 4 can be returned to the consumer so that it can read and execute the message content in message 4.

[0074] S102. Generate the identifier of the target message and cache the correspondence between the target message and the identifier in the historical message record.

[0075] For example, the identifier can be a unique identifier generated by Redis for the target message according to predefined rules.

[0076] S103. Return the first read information to the target consumer.

[0077] The first read information includes an identifier and a target message, which instructs the target consumer to read and execute the message content in the target message, and to initiate a second read instruction if the execution fails. The second read instruction initiated by the target consumer may carry at least an identifier, and the second read instruction initiated by the target consumer can be used to retrieve the target message again, and to read and execute it.

[0078] Optionally, after returning the first read information to the target consumer, the message processing method provided in this application embodiment may further include: upon receiving a second read instruction from the target consumer, searching for the target message from historical message records based on an identifier; and returning the second read information to the target consumer.

[0079] The second read information includes at least the target message, which instructs the target consumer to read and execute the message content in the target message again.

[0080] After Redis returns the first read information containing the identifier and the target message to the target consumer, the target message can be deleted from the message queue accordingly. Once the target consumer obtains the target message, it can add it to its own execution queue and read and execute messages sequentially. When reading and executing messages in the execution queue, the target consumer can delete a message while processing it. However, if task execution fails due to temporary network failures, there is no fault tolerance mechanism, resulting in poor reliability of the entire message processing system. Therefore, in this embodiment, the mapping between the target message and the identifier can be cached in the historical message record before returning the first read information. This allows the target consumer to initiate a second read command to retrieve the target message from the historical message record and execute it again in case of execution failure. Therefore, this embodiment can improve the reliability of the entire message processing system.

[0081] Optionally, the second read information is also used to instruct the target consumer to return failure feedback information in the event of a second execution failure; after returning the second read information to the target consumer, the message processing method provided in this application embodiment may further include: upon receiving the failure feedback information returned by the target consumer, searching for the corresponding target message from the historical message record based on the identifier carried in the failure feedback information; and returning the target message to the target producer corresponding to the target message, instructing the target producer to perform a rollback operation on the target message.

[0082] In this embodiment, if the target consumer fails to execute the message content of the target message twice, it can return failure feedback information. Redis can then return the target message to the target producer corresponding to the target message based on this failure feedback information. The target producer can perform rollback operations on the target message, such as reversing previously generated business operations. This ensures data consistency between the server system corresponding to the producer and the client system corresponding to the consumer when the task execution fails.

[0083] Optionally, the identifier includes a flag bit, which is used to represent the number of times the target message is executed, and the initial value of the flag bit is a preset value. Searching for the target message in the historical message record based on the identifier may include: determining whether the flag bit meets the preset conditions; if the flag bit meets the preset conditions, searching for the target message in the historical message record based on the identifier; returning the second read information to the target consumer may include: updating the flag bit, updating the identifier in the historical message record according to the updated flag bit, and returning the second read information to the target consumer.

[0084] The second read information also includes an updated identifier, which is used to instruct the target consumer to initiate a second read command again in the event of execution failure.

[0085] The preset value can be a predetermined value, such as 1.

[0086] The preset condition can be a pre-determined condition, such as the current value of the flag bit being less than or equal to a preset threshold.

[0087] The preset threshold can be a predetermined value, for example, the preset threshold can be 3 or 4.

[0088] For example, updating a flag bit means incrementing its current value by one. For instance, if the flag bit's current value is 1, updating it means setting it to 2.

[0089] In this embodiment, a flag bit can be added to the identifier to indicate the number of times the target message has been executed. When a second read instruction is received from the target consumer, the value of the flag bit in the identifier of the second read instruction can be compared with a preset threshold. This preset threshold can represent the maximum number of times the same task is allowed to be executed. If the value of the flag bit does not reach the preset threshold, the target message can be found in the historical message queue and returned to the target consumer, allowing the target consumer to read and execute the message content of the target message again. In this way, the number of times the consumer can execute the same task can be further increased.

[0090] Optionally, after determining whether the flag bit meets the preset conditions, the message processing method provided in this application embodiment may further include: if it is determined that the flag bit does not meet the preset conditions, returning the target message to the target producer corresponding to the target message to instruct the target producer to perform a rollback operation on the target message.

[0091] In the event that the target consumer fails to execute the task multiple times, in order to ensure the consistency of data between the server system corresponding to the producer and the client system corresponding to the consumer, this embodiment of the application can return the target message to the target producer corresponding to the target message when the value of the flag bit of the identifier in the second read instruction reaches a preset threshold, so that the target producer can perform a rollback operation on the target message.

[0092] Optionally, after returning the target message to the target producer corresponding to the target message, the message processing method provided in this application embodiment may further include: deleting the correspondence between the target message and the identifier cached in the historical message record.

[0093] If the execution of the target message fails multiple times, the target message can be considered a bad message. To avoid an excessive number of bad messages in the historical message record, which would affect the efficiency of Redis querying target messages based on identifiers, this embodiment of the application can delete these bad messages.

[0094] Optionally, the identifier may also include the execution status of the target message; the first read information is further used to instruct the target consumer to return success feedback information if the execution is successful; the message processing method provided in this application embodiment may further include: updating the execution status upon receiving success feedback information returned by the target consumer.

[0095] For example, the execution status of the target message may include a non-executed status, a read status, an execution successful status, and an execution failed status.

[0096] In this embodiment, the execution status of the target message can be added to the identifier, and this execution status can be updated according to the actual execution process. In this way, the client system or server system can query all messages and execution statuses at any time in the front-end asynchronous task query interface to achieve message monitoring and data analysis.

[0097] In summary, the message processing method provided in this application does not directly return the determined target message to the target consumer upon receiving the first read instruction from the target consumer. Instead, it first generates an identifier for the target message and caches the correspondence between the target message and the identifier in the historical message record. Then, it returns the first read information containing the identifier and the target message to the target consumer. Thus, if the target consumer fails to read and execute the message content of the target message for the first time, it can re-initiate a second read instruction based on the identifier in the first read information to retrieve, read, and execute the target message again. It can be seen that this application sets up a compensation mechanism for the target consumer's task execution process. By generating an identifier for the target message and storing the correspondence between the target message and the identifier in the historical message record, the target consumer can easily retrieve the target message and execute the task again when the task execution fails. This increases the number of times the consumer can execute the same task, thereby increasing the probability of successful task execution and improving the user experience.

[0098] Optional, such as Figure 3 As shown in the embodiments of this application, a message processing method is also provided, which may include S301-S307:

[0099] S301. Upon receiving the first read instruction from the target consumer, determine the target message from the message queue based on the first read instruction.

[0100] S302. Generate the identifier of the target message and cache the correspondence between the target message and the identifier in the historical message record.

[0101] S303, Return the first read information to the target consumer.

[0102] S304. Upon receiving a second read instruction from the target consumer, search for the target message from the historical message record based on the identifier.

[0103] S305, Return the second read information to the target consumer.

[0104] S306. Upon receiving a failure feedback message from the target consumer, search for the corresponding target message in the historical message record based on the identifier carried in the failure feedback message.

[0105] S307. Return the target message to the target producer corresponding to the target message, which is used to instruct the target producer to perform a rollback operation on the target message.

[0106] Optional, such as Figure 4 As shown in the embodiments of this application, a message processing method is also provided, which may include S401-S407:

[0107] S401. Upon receiving the first read instruction from the target consumer, determine the target message from the message queue based on the first read instruction.

[0108] S402. Generate the identifier of the target message and cache the correspondence between the target message and the identifier in the historical message record.

[0109] S403: Return the first read information to the target consumer.

[0110] S404. Upon receiving a second read instruction from the target consumer, determine whether the flag bit meets the preset conditions.

[0111] If the flag bit meets the preset conditions, then proceed to step S405; if the flag bit does not meet the preset conditions, then proceed to step S407.

[0112] S405. Search for the target message from historical message records based on the identifier.

[0113] S406. Update the flag bit, update the identifier in the historical message record according to the updated flag bit, and return the second read information to the target consumer.

[0114] S407. Return the target message to the target producer corresponding to the target message, which is used to instruct the target producer to perform a rollback operation on the target message.

[0115] like Figure 5 As shown in the figure, this application embodiment also provides a message processing device, which may include: a determination module 11, a cache module 21 and a return module 31.

[0116] Specifically, the determining module 11 executes S101 in the above method embodiment, the caching module 21 executes S102 in the above method embodiment, and the returning module 31 executes S103 in the above method embodiment.

[0117] The determination module 11 is used to determine the target message from the message queue based on the first read instruction received from the target consumer.

[0118] The caching module 21 is used to generate the identifier of the target message and cache the correspondence between the target message and the identifier in the historical message record;

[0119] The return module 31 is used to return first read information to the target consumer; the first read information contains an identifier and a target message, which is used to instruct the target consumer to read and execute the message content in the target message, and to initiate a second read instruction if the execution fails; the second read instruction carries at least an identifier, which is used to reacquire the target message, and to read and execute it.

[0120] Optionally, in one possible design, the message processing apparatus provided in this application may further include: a lookup module;

[0121] The lookup module is used to look up the target message from the historical message record based on the identifier after the return module 31 returns the first read information to the target consumer and receives the second read instruction from the target consumer.

[0122] The return module 31 is also used to return second read information to the target consumer; the second read information contains at least the target message, which is used to instruct the target consumer to read and execute the message content in the target message again.

[0123] Optionally, in another possible design approach, the second read information is also used to instruct the target consumer to return failure feedback information in the event of a second execution failure;

[0124] The lookup module is also used to look up the corresponding target message from the historical message record based on the identifier carried in the failure feedback information after the return module 31 returns the second read information to the target consumer and receives the failure feedback information returned by the target consumer.

[0125] The return module 31 is also used to return the target message to the target producer corresponding to the target message, so as to instruct the target producer to perform a rollback operation on the target message.

[0126] Optionally, in another possible design approach, the identifier includes a flag bit that represents the number of times the target message is executed, and the initial value of the flag bit is a preset value.

[0127] The search module is specifically used to: determine whether the flag bit meets the preset conditions; and if the flag bit meets the preset conditions, search for the target message from the historical message record based on the identifier.

[0128] The return module 31 is specifically used to: update the flag bit, update the identifier in the historical message record according to the updated flag bit, and return the second read information to the target consumer; the second read information also includes the updated identifier, and is also used to instruct the target consumer to initiate the second read instruction again in the event of execution failure.

[0129] Optionally, in another possible design, the return module 31 is also used for:

[0130] After the lookup module determines whether the flag meets the preset conditions, if it determines that the flag does not meet the preset conditions, it returns the target message to the target producer corresponding to the target message, instructing the target producer to perform a rollback operation on the target message.

[0131] Optionally, in another possible design, the message processing apparatus provided in this application may also include a deletion module;

[0132] The deletion module is used to delete the mapping between the target message and the identifier cached in the historical message record after the return module 31 returns the target message to the target producer corresponding to the target message.

[0133] Optionally, in another possible design, the identifier also includes the execution status of the target message; the first read information is also used to instruct the target consumer to return success feedback information if the execution is successful; the message processing apparatus provided in this application may also include an update module;

[0134] The update module is used to update the execution status upon receiving a success feedback message from the target consumer.

[0135] Optionally, the message processing device may also include a storage module for storing the program code of the message processing device, etc.

[0136] like Figure 6 As shown, this application embodiment also provides a message processing device, including a memory 41 and a processor (e.g., Figure 6The processor includes 42-1 and 42-2, bus 43 and communication interface 44; memory 41 is used to store computer execution instructions, and the processor and memory 41 are connected through bus 43; when the message processing device is running, the processor executes the computer execution instructions stored in memory 41 so that the message processing device performs the message processing method provided in the above embodiments.

[0137] In a specific implementation, as one example, the processor may include one or more central processing units (CPUs), for example... Figure 6 CPU0 and CPU1 are shown in the diagram. As one embodiment, the message processing device may include multiple processors, such as... Figure 6 The processors 42-1 and 42-2 are shown in the diagram. Each of these processors (CPUs) can be a single-core processor or a multi-core processor. Here, "processor" can refer to one or more devices, circuits, and / or processing cores used to process data (e.g., computer program instructions).

[0138] The memory 41 may be a read-only memory (ROM) or other type of static storage device capable of storing static information and instructions, random access memory (RAM) or other type of dynamic storage device capable of storing information and instructions, or electrically erasable programmable read-only memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital versatile optical discs, Blu-ray discs, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but not limited thereto. The memory 41 may exist independently and be connected to the processor via bus 43. The memory 41 may also be integrated with the processor.

[0139] In a specific implementation, memory 41 is used to store the data in this application and the computer execution instructions corresponding to the software program of this application. The processor can run or execute the software program stored in memory 41, and call the data stored in memory 41, as well as various functions of the message processing device.

[0140] Communication interface 44 uses any transceiver-like device for communicating with other devices or communication networks, such as control systems, radio access networks (RAN), wireless local area networks (WLANs), etc. Communication interface 44 may include a receiving unit to implement receiving functions and a transmitting unit to implement transmitting functions.

[0141] Bus 43 can be an industry standard architecture (ISA) bus, a peripheral component interconnect (PCI) bus, or an extended industry standard architecture (EISA) bus, etc. This bus 43 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0142] As an example, combined Figure 5 The return module in the message processing device performs the same functions as... Figure 6 The sending unit in the message processing device performs the same function as the buffer module in the message processing device. Figure 6 The processor in the memory performs the same function. When the message processing device includes a storage module, the storage module performs the same function as... Figure 6 The memory in them performs the same function.

[0143] The explanation of the relevant content in this embodiment can be found in the above method embodiment, and will not be repeated here.

[0144] Through the above description of the embodiments, those skilled in the art will clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. The specific working process of the system, device, and unit described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0145] This application also provides a computer-readable storage medium storing instructions that, when executed by a computer, cause the computer to perform the message processing method provided in the above embodiments.

[0146] The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium (a non-exhaustive list) include: an electrical connection having one or more wires, a portable computer disk, a hard disk, RAM, ROM, an erasable programmable read-only memory (EPROM), a register, a hard disk, an optical fiber, a CD-ROM, an optical storage device, a magnetic storage device, or any suitable combination thereof, or any other form of computer-readable storage medium known in the art. An exemplary storage medium is coupled to a processor, enabling the processor to read information from and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can reside in an application-specific integrated circuit (ASIC). In embodiments of this application, the computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.

[0147] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A message processing method, characterized in that, include: Upon receiving a first read instruction from the target consumer, the target message is determined from the message queue based on the first read instruction; Generate an identifier for the target message, and cache the correspondence between the target message and the identifier in the historical message record; Return the first read information to the target consumer; The first read information includes the identifier and the target message, which is used to instruct the target consumer to read and execute the message content in the target message, and to initiate a second read instruction if the execution fails; the second read instruction carries at least the identifier, and is used to reacquire the target message, and read and execute it; After returning the first read information to the target consumer, the method further includes: Upon receiving a second read instruction from the target consumer, the target message is retrieved from the historical message record based on the identifier; The second read information is returned to the target consumer; the second read information includes at least the target message, which instructs the target consumer to read and execute the message content in the target message again; The identifier is a unique identifier generated by Redis for the target information according to predetermined rules.

2. The message processing method according to claim 1, characterized in that, The second read information is also used to instruct the target consumer to return failure feedback information in the event of a second execution failure; after returning the second read information to the target consumer, the method further includes: Upon receiving the failure feedback information returned by the target consumer, the corresponding target message is retrieved from the historical message record based on the identifier carried in the failure feedback information. The target message is returned to the target producer corresponding to the target message, instructing the target producer to perform a rollback operation on the target message.

3. The message processing method according to claim 1, characterized in that, The identifier includes a flag bit, which is used to characterize the number of times the target message is executed, and the initial value of the flag bit is a preset value; The step of searching for the target message from the historical message record based on the identifier includes: Determine whether the flag bit meets a preset condition; if the flag bit meets the preset condition, search for the target message from the historical message record based on the identifier; The step of returning the second read information to the target consumer includes: updating the flag bit, updating the identifier in the historical message record according to the updated flag bit, and returning the second read information to the target consumer; the second read information also includes the updated identifier, and is also used to instruct the target consumer to re-initiate the second read instruction in the event of execution failure.

4. The message processing method according to claim 3, characterized in that, After determining whether the flag bit meets the preset conditions, the method further includes: If it is determined that the flag does not meet the preset condition, the target message is returned to the target producer corresponding to the target message to instruct the target producer to perform a rollback operation on the target message.

5. The message processing method according to claim 2 or 4, characterized in that, After returning the target message to the target producer corresponding to the target message, the method further includes: Delete the mapping between the target message and the identifier cached in the historical message record.

6. The message processing method according to claim 1, characterized in that, The identifier also includes the execution status of the target message; the first read information is further used to instruct the target consumer to return success feedback information if the execution is successful; the method further includes: Upon receiving the success feedback information from the target consumer, the execution status is updated.

7. A message processing device, characterized in that, include: The determination module is used to determine the target message from the message queue based on the first read instruction received from the target consumer. A caching module is used to generate an identifier for the target message and cache the correspondence between the target message and the identifier in the historical message record; The return module is used to return the first read information to the target consumer; The first read information includes the identifier and the target message, and is used to instruct the target consumer to read and execute the message content in the target message, and to initiate a second read instruction if the execution fails; The second read instruction carries at least the identifier and is used to reacquire the target message, read it, and execute it. The device further includes: The lookup module is configured to, after the return module returns the first read information to the target consumer, and upon receiving the second read instruction from the target consumer, search for the target message based on the identifier in the historical message record. The return module is further configured to return second read information to the target consumer; the second read information includes at least the target message, which instructs the target consumer to read and execute the message content in the target message again; The identifier is a unique identifier generated by Redis for the target information according to predetermined rules.

8. A message processing device, characterized in that, It includes a memory, a processor, a bus, and a communication interface; the memory is used to store computer-executed instructions, and the processor is connected to the memory via the bus; When the message processing device is running, the processor executes the computer execution instructions stored in the memory to cause the message processing device to perform the message processing method as described in any one of claims 1-6.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores instructions that, when executed by a computer, cause the computer to perform the message processing method as described in any one of claims 1-6.