Transaction execution method, system, electronic device and readable medium

By introducing a dual-queue mechanism into the distributed transaction system to manage the status of successful execution messages, the inconsistency problem caused by the instability of message middleware transactions is solved, and eventual consistency and message communication reliability of the distributed transaction system are achieved.

CN115202831BActive Publication Date: 2026-02-17JINGDONG TECH HLDG CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110392832.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-04-13
Publication Date
2026-02-17
Estimated Expiration
2041-04-13

AI Technical Summary

Technical Problem

Existing distributed transaction solutions, when aiming for eventual consistency, suffer from unstable transactions in message middleware, which can easily lead to message loss and consumption anomalies, resulting in transaction inconsistency issues.

Method used

A dual-queue mechanism is adopted, which ensures the status management of successful execution messages through message table and queue interaction between the first and second nodes, thereby achieving eventual consistency of the distributed transaction system.

Benefits of technology

It achieves eventual consistency in distributed transaction systems, avoids inconsistency issues caused by transaction instability in message middleware, and ensures the reliability and integrity of message communication between services.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115202831B_ABST
    Figure CN115202831B_ABST
Patent Text Reader

Abstract

This disclosure provides a transaction execution method, system, electronic device, and readable medium. The method includes: receiving an execution instruction for a target transaction; operating on a first database according to the target transaction to obtain an execution success message and sending the execution success message to a message table; sending the execution success message to a first queue; listening to feedback messages in a second queue, wherein the feedback messages are generated by a second node in the transaction execution system after operating on a second database based on the execution success message in the first queue, and then sending the feedback messages to the second queue; and changing the status of the execution success messages in the message table according to the feedback messages, thereby managing the target transaction based on the status of the execution success messages in the message table. The transaction execution method, system, electronic device, and readable medium provided by this disclosure can guarantee the eventual consistency of a distributed transaction system.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present disclosure relates to the technical field of database operation, and particularly relates to a transaction execution method and system, an electronic device and a computer readable medium. BACKGROUND

[0002] In a traditional architecture, it is often a single architecture, one application corresponds to one database, at this time, the traditional database transaction can meet the traditional database transaction and meet the strong consistency. However, with the interaction of business between microservices or upstream and downstream systems, the traditional single transaction cannot meet the requirements, and the distributed transaction appears. The emergence of the theory of distributed transaction also introduces new principles, which are CAP principle and BASE theory.

[0003] The CAP principle describes the basic principles in the distributed system, in which C refers to consistency, A refers to availability, and P refers to partition tolerance. The CAP principle means that the three elements can at most realize two points at the same time, and it is impossible to realize all three. Either CP is satisfied at the same time, that is, partition tolerance and consistency are satisfied at the same time, or AP is satisfied at the same time, that is, partition tolerance and availability are satisfied at the same time. From this, it can be seen that P is the basis of the distributed system, and there is no partition tolerance in the distributed system. The reason why CAP can only satisfy AP or CP is that there is usually a data copying process between distributed nodes, and in this process, only AP or CP can be satisfied.

[0004] The BASE theory is the result of the trade-off between consistency and availability in the CAP principle. BASE is a short form of the three phrases of (Basically Available), (Soft state) and (Eventual consistency).

[0005] Basically available means that in the distributed cluster nodes, if a node is down or in the process of data replication between nodes, only part of the data is unavailable, but it does not affect the overall availability of the entire system.

[0006] Soft state means that this state is only an intermediate state, and allows a time delay in the operation process between nodes in the cluster. The intermediate state will eventually be converted into a final state.

[0007] Eventual consistency means that there is a time delay in the operation process between the distributed cluster nodes. In contrast to ACID, eventual consistency is not strong consistency. After a certain period of time, the data copying between the distributed cluster nodes can reach a state of eventual consistency.

[0008] Currently, commonly used distributed solutions have, for example, a message middleware-based eventual consistency solution. However, the target distributed solution often causes transaction inconsistency when facing eventual consistency, because the message middleware transaction is unstable, and there are uncontrollable factors such as message loss and consumption exception.

[0009] Therefore, there is a need for a new transaction execution method, system, electronic device, and computer readable medium.

[0010] The above information disclosed in the background section is only intended to strengthen the understanding of the background of the present disclosure, and therefore it can include information that does not constitute prior art known to those of ordinary skill in the art. SUMMARY

[0011] Therefore, the embodiments of the present disclosure provide a transaction execution method, system, electronic device, and computer readable medium, which can meet the eventual consistency of the distributed transaction system.

[0012] Other characteristics and advantages of the present disclosure will become apparent from the following detailed description, or will be learned by practice of the present disclosure.

[0013] According to a first aspect of the embodiments of the present disclosure, a transaction execution method is provided, which is executed by a first node in a transaction execution system, the first node comprising a first database, and the method comprises: receiving an execution instruction of a target transaction; operating the first database according to the target transaction to obtain an execution success message and sending the execution success message to a message table; sending the execution success message to a first queue; listening to a feedback message in a second queue, the feedback message being generated by a second node in the transaction execution system according to the execution success message in the first queue operating a second database of the second node and sent to the second queue; changing a state of the execution success message in the message table according to the feedback message, so as to manage the target transaction according to the state of the execution success message in the message table.

[0014] In an exemplary embodiment of the present disclosure, managing the target transaction according to the state of the execution success message comprises: re-sending the execution success message in the message table whose state has not been changed to the first queue in a polling manner, so that the second node operates the second database according to the re-sent execution success message and sends the feedback message to the second queue.

[0015] In an exemplary embodiment of this disclosure, the target transaction includes first execution logic and message table writing logic; wherein, operating on the first database according to the target transaction to obtain an execution success message and sending the execution success message to the message table includes: obtaining the execution success message by executing the first execution logic, operating on the first database according to the execution success message; sending the execution success message to the message table, and setting the status of the execution success message to sending.

[0016] In one exemplary embodiment of this disclosure, changing the status of the execution success message in the message table according to the feedback message to manage the target transaction according to the status of the execution success message in the message table includes: modifying the status of the execution success message in the message table to "sent" according to the feedback message; resending the execution success messages in the message table with the status "sent" to the first queue through a polling method, so that the second node operates on the second database according to the resent execution success message and sends the feedback message to the second queue.

[0017] According to a third aspect of the present disclosure, a transaction execution method is proposed, executed by a second node in a transaction execution system, the second node having a second database. The method includes: listening to and obtaining an execution success message from a first queue, the execution success message being generated by the first node in the transaction execution system after performing operations on a first database on the first node's local machine according to a target transaction, the execution success message also being written into a message table on the first node's local machine; performing operations on the second database according to the execution success message to obtain a feedback message; sending the feedback message to a second queue, so that the first node changes the status of the execution success message in the message according to the feedback message in the second queue, and manages the target transaction according to the status of the execution success message in the message table.

[0018] In one exemplary embodiment of this disclosure, the method further includes: when failing to obtain the execution success message from the first queue, obtaining a resent execution success message from the first queue, wherein the resent execution success message is resent by the first node to the first queue according to the status of the execution success message in its local message table; operating on the second database according to the resent execution success message to obtain the feedback message; and sending the feedback message to the second queue so that the first node in the transaction execution system can manage the status of the execution success message according to the feedback message in the second queue.

[0019] In one exemplary embodiment of this disclosure, the method further includes: when an operation on the second database fails based on the execution success message, listening to and obtaining a resent execution success message from a first queue, wherein the resent execution success message is resent by the first node to the first queue based on the status of the execution success message in its local message table; operating on the second database based on the resent execution success message to obtain the feedback message; and sending the feedback message to a second queue so that the first node in the transaction execution system can manage the status of the execution success message based on the feedback message in the second queue.

[0020] According to a third aspect of the present disclosure, a transaction execution system is proposed, comprising: a first node including a first database, the first node being configured to receive an execution instruction for a target transaction; operate on the first database according to the target transaction to obtain an execution success message and send the execution success message to a message table; send the execution success message to a first queue; listen for feedback messages in a second queue; and change the status of the execution success message in the message table according to the feedback message, so as to manage the target transaction according to the status of the execution success message in the message table. A second node including a second database, the second node being configured to listen for the execution success message from the first queue; perform operations on the second database according to the execution success message to obtain a feedback message; and send the feedback message to the second queue.

[0021] According to a fourth aspect of the present disclosure, an electronic device is provided, comprising: one or more processors; a storage device for storing one or more programs; and, when the one or more programs are executed by the one or more processors, causing the one or more processors to implement the transaction execution method described in any of the preceding claims.

[0022] According to a fifth aspect of the present disclosure, a computer-readable medium is provided having a computer program stored thereon, which, when executed by a processor, implements the transaction execution method as described in any of the preceding claims.

[0023] According to certain embodiments of the transaction execution method, system, electronic device, and computer-readable medium provided in this disclosure, when operating on the first database based on the target transaction, obtaining an execution success message and sending the execution success message to a message table can ensure strong consistency of the local transaction of the first node. The execution success message generated after the target transaction is executed is sent to a first queue; and after listening to the feedback message generated by the second node based on the execution success message, the status of the execution success message in the management message table is adjusted according to the feedback message, and the target transaction is managed based on the status of the execution success message in the message table. This allows for real-time tracking of the interaction status between the first and second nodes based on the target transaction, and management of the target transaction based on this interaction status. This ensures eventual consistency of the distributed transaction system and avoids inconsistencies caused by message middleware transactions due to instability, message loss, consumption anomalies, or other uncontrollable factors. Simultaneously, the dual-queue mechanism formed by the first and second queues further guarantees the reliability and integrity of message communication between services.

[0024] It should be understood that the above general description and the following detailed description are merely exemplary and do not limit this disclosure. Attached Figure Description

[0025] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure. The drawings described below are merely some embodiments of this disclosure, and those skilled in the art will be able to derive other drawings from these drawings without any inventive effort.

[0026] Figure 1 This is a system block diagram illustrating a transaction execution method and apparatus according to an exemplary embodiment.

[0027] Figure 2 This is a flowchart illustrating a transaction execution method according to an exemplary embodiment.

[0028] Figure 3 This is a flowchart illustrating a transaction execution method according to an exemplary embodiment.

[0029] Figure 4 This is a flowchart illustrating a transaction execution method according to an exemplary embodiment.

[0030] Figure 5 This is a block diagram illustrating a transaction execution system according to an exemplary embodiment.

[0031] Figure 6 The diagram schematically illustrates a block diagram of an electronic device according to an exemplary embodiment of the present disclosure. Detailed Implementation

[0032] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the embodiments set forth herein; rather, they are provided so that the invention will be thorough and complete, and the concept of the exemplary embodiments will be fully conveyed to those skilled in the art. The same reference numerals in the drawings denote the same or similar parts, and therefore repeated descriptions of them will be omitted.

[0033] The described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. Numerous specific details are provided in the following description to give a full understanding of embodiments of the invention. However, those skilled in the art will recognize that the technical solutions of the invention can be practiced with one or more specific details omitted, or other methods, components, apparatuses, steps, etc., can be employed. In other instances, well-known methods, systems, implementations, or operations are not shown or described in detail to avoid obscuring aspects of the invention.

[0034] The accompanying drawings are merely illustrative of the invention; the same reference numerals denote the same or similar parts, and therefore repeated descriptions of them will be omitted. Some block diagrams shown in the drawings do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.

[0035] The flowchart shown in the accompanying drawings is merely illustrative and does not necessarily include all content and steps, nor does it require execution in the described order. For example, some steps may be broken down, while others may be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.

[0036] The exemplary embodiments of the present invention will now be described in detail with reference to the accompanying drawings.

[0037] Figure 1 This is a system block diagram illustrating a transaction execution method and apparatus according to an exemplary embodiment.

[0038] In the system 100 of the transaction execution method and apparatus, the server 105 may be a server that provides various services, such as a background management server that provides support for the transaction execution system operated by users using terminal devices 101, 102, and 103 via network 104 (for example only). The background management server can analyze and process data such as received transaction execution requests, and feed back the processing results (such as the status of a successful execution message - for example only) to the terminal devices.

[0039] Server 105 can be a single physical server, or it can be composed of multiple servers. Server 105 can also serve as the server of the first node in the transaction execution system of this disclosure, for example, to receive the execution instructions of the target transaction; to operate on the first database according to the target transaction, obtain an execution success message and send the execution success message to a message table; to send the execution success message to a first queue; to listen for feedback messages in a second queue, the feedback messages being generated by the second node in the transaction execution system after operating on the second database of the second node according to the execution success message in the first queue, and sent to the second queue; and to change the status of the execution success message in the message table according to the feedback message, so as to manage the target transaction according to the status of the execution success message in the message table.

[0040] Server 105 can also serve as the server of the second node in the transaction execution system, used to listen for execution success messages from the first queue. The execution success message is generated by the first node in the transaction execution system after operating on the first database on the first node's local machine according to the target transaction. The execution success message is also used to write to the message table on the first node's local machine. Based on the execution success message, the server performs operations on the second database to obtain feedback messages. The server sends the feedback messages to the second queue so that the first node can change the status of the execution success message in the message according to the feedback messages in the second queue, and manage the target transaction according to the status of the execution success message in the message table.

[0041] Figure 2 This is a flowchart illustrating a transaction execution method according to an exemplary embodiment. The transaction execution method provided in this disclosure can be executed by any electronic device with computing power, such as terminal devices 101, 102, 103 and / or server 105. In the following embodiments, the method is illustrated by example with a server executing the method, but this disclosure is not limited thereto. The transaction execution method provided in this disclosure may include steps S202 to S208.

[0042] The transaction execution method of this disclosure can be executed by a first node in a transaction execution system, the first node including a first database. The transaction execution system can be a distributed cluster.

[0043] like Figure 2 As shown, in step S202, the execution instruction of the target transaction is received.

[0044] In this embodiment of the disclosure, the target transaction is used to implement operations on a first database. For example, when the first node is a payment system, the target transaction may include payment logic. This payment logic can be used to perform read and / or write operations on payment data in the first database. The target transaction may be obtained by the first node when executing its local program, or it may be received from an external node; the embodiments of this disclosure do not impose any special limitations on this.

[0045] In step S204, the first database is operated on according to the target transaction to obtain an execution success message and send the execution success message to the message table.

[0046] In this embodiment of the disclosure, for example, when the first node is a payment system and the target transaction includes payment logic, the execution success message can be a payment success message. This execution success message may include, for example, payment details, a unique identifier (e.g., a transaction serial number), and information about the parties involved in the payment. The target transaction may include payment logic and the logic for inserting into the message table. That is, the payment logic and the logic for inserting into the message table are wrapped in one transaction, thereby ensuring strong consistency of the local transaction.

[0047] The message table can include the execution success message obtained after each target transaction is executed, as well as the status of the execution success message. When sending the execution success message to the message table, the status of the execution success message can be set to the first status.

[0048] In step S206, a success message is sent to the first queue.

[0049] In this example disclosure, the first queue may be, for example, a message queue.

[0050] In step S208, the feedback message in the second queue is monitored. The feedback message is generated by the second node in the transaction execution system after it operates on the second database of the second node based on the execution success message in the first queue, and then sent to the second queue.

[0051] In this embodiment, the second node can listen for execution success messages in the first queue. Upon receiving a payment success message, it operates on its local second database based on that message, i.e., by executing local transactions to read and / or write to the second database, and then generates a feedback message. The second queue can be implemented using a similar technique to the first queue. The feedback message generated by the second node may include a unique identifier corresponding to the execution success message.

[0052] In this system, the target transaction not only triggers operations on the first database in the first node but also triggers operations on the second database in the second node. For example, when the first node is a payment system and the target transaction includes payment logic, the second node could be a ledger system. The second node can execute consumption logic and generate ledger records based on the execution result of the target transaction (i.e., the execution success message). For instance, idempotency can be implemented to prevent duplicate consumption.

[0053] In step S210, the status of the execution success message in the message table is changed according to the feedback message, so as to manage the target transaction according to the status of the execution success message.

[0054] In this embodiment of the disclosure, after receiving a feedback message, the corresponding execution success message can be retrieved from the message table based on the unique identifier in the feedback message, and the status recorded in the message table for the execution success message can be changed, for example, from a first status to a second status. Based on the change of the status of the execution success message in the message table, the interaction status of the first node and the second node based on the target transaction can be tracked in real time according to the message table, and the target transaction can be managed according to the interaction status to ensure the consistency of the target transaction execution on the first node and the second node.

[0055] According to the transaction execution method provided in this disclosure, when operating on the first database based on the target transaction, obtaining an execution success message and sending the execution success message to the message table can ensure strong consistency of the local transaction of the first node. The execution success message generated after the target transaction is executed is sent to the first queue; and after listening to the feedback message generated by the second node based on the execution success message, the status of the execution success message in the management message table is adjusted according to the feedback message, and the target transaction is managed based on the status of the execution success message in the message table. This allows for real-time tracking of the interaction status between the first and second nodes based on the target transaction, and management of the target transaction based on this interaction status. This ensures eventual consistency of the distributed transaction system and avoids inconsistencies caused by message middleware transactions due to instability, message loss, consumption anomalies, or other uncontrollable factors. Simultaneously, the dual-queue mechanism formed by the first and second queues further guarantees the reliability and integrity of message communication between services.

[0056] In an exemplary embodiment, when managing the target transaction based on the status of the execution success message, the execution success message whose status has not changed in the message table can be resent to the first queue in a polling manner, so that the second node can operate on the second database based on the resent execution success message and send a feedback message to the second queue.

[0057] For example, for an execution success message with a status of "second state" in the message table, it is considered that the interaction logic between the first and second nodes based on the target transaction has been completed, and the read and write operations on the first and second databases related to the target transaction can be kept consistent, thus achieving eventual consistency of the distributed transaction. For execution success messages with a status of "first state" in the message table, the message is sent again to the first queue, and execution steps S208 to S210 are returned.

[0058] In an exemplary embodiment, the target transaction may include first execution logic and message table writing logic. Step S204 may include: obtaining an execution success message by executing the first execution logic, performing operations on the first database based on the execution success message; sending the execution success message to the message table, and setting the status of the execution success message to "sending".

[0059] Furthermore, in an exemplary embodiment, step S210 may include: modifying the status of the execution success message in the message table to "sent" according to the feedback message; resending the execution success message with the status of "sent" in the message table to the first queue through a polling method, so that the second node can operate on the second database according to the resent execution success message and send a feedback message to the second queue.

[0060] In this system, the first status of a successful execution message can be "sending" and the second status can be "sent". The first node sends successful execution messages with the status "sending" in the message table to the first queue using a polling method. This allows the system to track the interaction status of the first and second nodes based on the target transaction in real time, and then manage the target transaction according to this interaction status. This helps to avoid transaction inconsistencies caused by uncontrollable factors such as message loss and abnormal consumption in the message middleware.

[0061] In an exemplary embodiment, the transaction execution method based on the above embodiment may further include: if the status of the successful execution message in the message table is "sending", then the storage time length of the successful execution message in the message table is calculated; if the storage time length is greater than a preset time length, then an alarm message is generated based on the successful payment message.

[0062] For example, if at the current moment, the storage time of a successful execution message in the message table for a given "sending" status exceeds a preset time, it can be assumed that this successful execution message cannot be executed normally on the second node, failing to complete the interactive operation consistent with the first node. Generating alarm information allows for timely follow-up processing, preventing inconsistencies between the first and second nodes.

[0063] Figure 3 This is a flowchart illustrating a transaction execution method according to an exemplary embodiment.

[0064] The transaction execution method of this disclosure embodiment can be executed by a second node in a transaction execution system, and the second node has a second database. The transaction execution system can be a distributed cluster.

[0065] like Figure 3 As shown, the transaction execution method of this disclosure embodiment may include steps S302 to S306.

[0066] In step S302, a success message is obtained from the first queue. The success message is generated by the first node in the transaction execution system after it operates on the first database on its local machine according to the target transaction. The success message is also used to write to the message table on the local machine.

[0067] In step S304, an operation is performed on the second database based on the successful execution message, and a feedback message is obtained.

[0068] In this embodiment, the first node can be a payment system, and the second node can be a ledger system. When the target transaction includes payment logic, the second node can execute consumption logic based on the execution result of the target transaction (i.e., the execution success message), generate ledger records, and perform write operations on the second database. The consumption logic can, for example, perform "idempotent" processing to prevent duplicate consumption.

[0069] In step S306, a feedback message is sent to the second queue so that the first node can change the status of the execution success message in the message according to the feedback message in the second queue, and manage the target transaction according to the status of the execution success message in the message table.

[0070] According to the transaction execution method provided in this disclosure, when the second node interacts with the first node in the transaction execution system, it obtains an execution success message by listening and performs operations on the second database based on the execution success message. Since the execution success message is generated by the first node in the transaction execution system after performing operations on the first database on its local machine based on the target transaction, it enables the interaction process between the first node and the second node related to the target transaction. The second node sends feedback messages to the second queue so that the first node can change the status of the execution success message in the message based on the feedback messages in the second queue, and manage the target transaction based on the status of the execution success message in the message table. This allows for real-time tracking of the interaction status between the first node and the second node based on the target transaction, and management of the target transaction based on this interaction status. This avoids inconsistencies in the message middleware transaction caused by uncontrollable factors such as message loss and consumption anomalies. At the same time, the dual-queue mechanism formed by the first queue and the second queue further ensures the reliability and integrity of message communication between services.

[0071] In an exemplary embodiment, Figure 3 The illustrated embodiment may further include: when failing to obtain an execution success message from the first queue, obtaining a resent execution success message from the first queue, wherein the resent execution success message is resent by the first node to the first queue based on the status of the execution success message in its local message table; operating on the second database based on the resent execution success message to obtain a feedback message; and sending the feedback message to the second queue so that the first node in the transaction execution system can manage the status of the execution success message based on the feedback message in the second queue.

[0072] In an exemplary embodiment, Figure 3 The illustrated embodiment may further include: when an operation on the second database fails based on the execution success message, listening for a resent execution success message from the first queue, wherein the resent execution success message is resent by the first node to the first queue based on the status of the execution success message in its local message table; operating on the second database based on the resent execution success message to obtain a feedback message; and sending the feedback message to the second queue so that the first node in the transaction execution system can manage the status of the execution success message based on the feedback message in the second queue.

[0073] Figure 4 This is a flowchart illustrating a transaction execution method according to an exemplary embodiment. The transaction execution method provided in this disclosure may include steps S402 to S406.

[0074] like Figure 4 As shown, the transaction execution method of this disclosure embodiment can be applied to a transaction execution system, which may include a payment system 420 as a first node and a ledger system 430 as a second node. The transaction execution system may be a distributed cluster. The transaction execution system also includes a message recovery system 440.

[0075] In step S402, a message table is introduced into the payment database to record payment messages. That is, after a user successfully pays, while a payment success message is written to the business table, a payment success message is simultaneously inserted into this message table with a status of "sending". The payment logic and the code for inserting the message table can be wrapped within a single target transaction, ensuring strong consistency within the local transaction. In other words, the payment logic and the message inserted into the message table form a strongly consistent transaction; they either both succeed or both fail simultaneously.

[0076] In step S404, after completing the logic of S402, a payment success message is then sent to the first queue of the message middleware. The content of this payment success message is the same as the content of the payment success message stored in the payment database message table.

[0077] In step S406, the ledger system listens to the payment message in the first queue through the message middleware, processes the consumption logic according to the payment message, that is, starts to generate ledger records. Here, the ledger system needs to perform "idempotent" processing to prevent duplicate consumption.

[0078] In step S408, after the ledger record is generated, a message indicating successful consumption is sent back to the message middleware to the second queue.

[0079] In step S410, the payment service also listens for the message of successful consumption of this ledger service. When the payment service hears the message of successful consumption, it changes the message status of the local message table to "sent".

[0080] In step S412, the message recovery system periodically retrieves messages with a status of "sending" from the local message table and then re-delivers them to the message middleware. This node mainly prevents data inconsistency caused by failures during message delivery and consumption.

[0081] According to the transaction execution method provided in this disclosure, a dual-queue mechanism of the message middleware is introduced: the dual queues ensure the reliability and integrity of message communication between services. By introducing a local message table in the business database and binding the local message table with the business table, local transactions can be used to ensure the integrity and reliability of the business.

[0082] It should be clearly understood that this disclosure describes how specific examples are formed and used, but the principles of this disclosure are not limited to any details of these examples. Rather, based on the teachings of this disclosure, these principles can be applied to many other embodiments.

[0083] Those skilled in the art will understand that all or part of the steps of the above embodiments are implemented as a computer program executed by a central processing unit (CPU). When the computer program is executed by the CPU, it performs the functions defined by the methods provided in this disclosure. The program can be stored in a computer-readable storage medium, such as a read-only memory, a magnetic disk, or an optical disk.

[0084] Furthermore, it should be noted that the above figures are merely illustrative of the processes included in the method according to exemplary embodiments of this disclosure, and are not intended to be limiting. It is readily understood that the processes shown in the above figures do not indicate or limit the temporal order of these processes. Additionally, it is readily understood that these processes may be executed synchronously or asynchronously, for example, in multiple modules.

[0085] The following are embodiments of the apparatus disclosed herein, which can be used to execute embodiments of the method disclosed herein. For details not disclosed in the apparatus embodiments of this disclosure, please refer to the embodiments of the method disclosed herein.

[0086] Figure 5 This is a block diagram illustrating a transaction execution system according to an exemplary embodiment. (Refer to...) Figure 5 The transaction execution system 50 provided in this embodiment may include: a first node 502 and a second node 504.

[0087] In the transaction execution system 50, the first node 502 includes a first database 5022. The first node 502 is configured to receive the execution instruction of the target transaction; operate on the first database according to the target transaction to obtain an execution success message and send the execution success message to a message table; send the execution success message to a first queue; listen for feedback messages in a second queue; and change the status of the execution success message in the message table according to the feedback message, so as to manage the target transaction according to the status of the execution success message in the message table.

[0088] The second node 504 includes a second database 5042. The second node 504 is configured to listen for the execution success message from the first queue; perform operations on the second database according to the execution success message to obtain a feedback message; and send the feedback message to the second queue.

[0089] According to the transaction execution system provided in this embodiment, when operating on the first database based on the target transaction, obtaining an execution success message and sending the execution success message to a message table ensures strong consistency of the local transaction on the first node. The execution success message generated after the target transaction is executed is sent to a first queue. After listening to the feedback message generated by the second node based on the execution success message, the system manages the status of the execution success message in the message table based on the feedback message, and manages the target transaction based on the status of the execution success message in the message table. This allows for real-time tracking of the interaction status between the first and second nodes based on the target transaction, and management of the target transaction based on this interaction status. This ensures eventual consistency of the distributed transaction system and avoids inconsistencies caused by message middleware transactions due to instability, message loss, consumption anomalies, or other uncontrollable factors. Furthermore, the dual-queue mechanism formed by the first and second queues further guarantees the reliability and integrity of message communication between services.

[0090] The following reference Figure 6 To describe an electronic device 600 according to this embodiment of the present invention. Figure 6The electronic device 600 shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of the present invention.

[0091] like Figure 6 As shown, the electronic device 600 is manifested in the form of a general-purpose computing device. The components of the electronic device 600 may include, but are not limited to: at least one processing unit 610, at least one storage unit 620, and a bus 630 connecting different system components (including storage unit 620 and processing unit 610).

[0092] The storage unit stores program code that can be executed by the processing unit 610, causing the processing unit 610 to perform the steps described in the "Exemplary Methods" section of this specification according to various exemplary embodiments of the present invention. For example, the processing unit 610 can perform actions such as... Figure 2 The steps shown are as follows: Step S202: Receive the execution instruction of the target transaction; Step S204: Operate on the first database according to the target transaction, obtain an execution success message, and send the execution success message to the message table; Step S206: Send the execution success message to the first queue; Step S208: Listen for feedback messages in the second queue, the feedback messages are generated by the second node in the transaction execution system after operating on the second database of the second node according to the execution success message in the first queue, and sent to the second queue; Step S210: Change the status of the execution success message in the message table according to the feedback message, so as to manage the target transaction according to the status of the execution success message.

[0093] Storage unit 620 may include a readable medium in the form of a volatile storage unit, such as random access memory (RAM) 6201 and / or cache memory 6202, and may further include a read-only memory (ROM) 6203.

[0094] Storage unit 620 may also include a program / utility 6204 having a set (at least one) program module 6205, such program module 6205 including but not limited to: operating system, one or more application programs, other program modules and program data, each or some combination of these examples may include an implementation of a network environment.

[0095] Bus 630 can represent one or more of several types of bus structures, including a memory cell bus or memory cell controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus using any of the various bus structures.

[0096] Electronic device 600 can also communicate with one or more external devices 700 (e.g., keyboard, pointing device, Bluetooth device, etc.), and with one or more devices that enable a user to interact with electronic device 600, and / or with any device that enables electronic device 600 to communicate with one or more other computing devices (e.g., router, modem, etc.). This communication can be performed via input / output (I / O) interface 650. Furthermore, electronic device 600 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 660. As shown, network adapter 660 communicates with other modules of electronic device 600 via bus 630. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with electronic device 600, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0097] From the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, terminal device, or network device, etc.) to execute the methods according to the embodiments of this disclosure.

[0098] In exemplary embodiments of this disclosure, a computer-readable storage medium is also provided, on which a program product capable of implementing the methods described above is stored. In some possible embodiments, various aspects of the invention may also be implemented as a program product comprising program code that, when the program product is run on a terminal device, causes the terminal device to perform the steps of the various exemplary embodiments of the invention described in the "Exemplary Methods" section of this specification.

[0099] The program product may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may 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 readable storage media (a non-exhaustive list) include: an electrical connection having one or more wires, a portable disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0100] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of sending, propagating, or transmitting programs for use by or in conjunction with an instruction execution system, apparatus, or device.

[0101] The program code contained on the readable medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.

[0102] Program code for performing the operations of this invention can be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java and C++, and conventional procedural programming languages ​​such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0103] Furthermore, the above figures are merely illustrative of the processes included in the method according to exemplary embodiments of the present invention, and are not intended to be limiting. It is readily understood that the processes shown in the above figures do not indicate or limit the temporal order of these processes. Additionally, it is readily understood that these processes may be executed synchronously or asynchronously, for example, in multiple modules.

[0104] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and concept of this disclosure are indicated by the claims.

Claims

1. A transaction execution method, characterized in that, Executed by the first node in the transaction execution system, the first node including a first database, the method includes: Receive the execution instruction for the target transaction; The first database is operated according to the target transaction to obtain an execution success message and send the execution success message to the message table, and the status of the execution success message in the message table is set to sending. Send the execution success message to the first queue; Listen for feedback messages in the second queue. These feedback messages are generated by the second node in the transaction execution system after it operates on the second database of the second node based on the execution success message in the first queue, and then sent to the second queue. The status of the execution success message in the message table is changed according to the feedback message, so as to manage the target transaction according to the status of the execution success message in the message table, including: Based on the feedback message, change the status of the execution success message in the message table to "sent"; The execution success message in the message table with a status of "sending" is resent to the first queue by polling, so that the second node can operate on the second database based on the resent execution success message and send the feedback message to the second queue.

2. The method as described in claim 1, characterized in that, Managing the target transaction based on the status of the execution success message includes: The second node resends the execution success messages whose status in the message table has not changed to the first queue by polling, so that the second node can operate on the second database based on the resent execution success messages and send the feedback message to the second queue.

3. The method as described in claim 1, characterized in that, The target transaction includes a first execution logic and a message table writing logic; wherein, operating the first database according to the target transaction to obtain an execution success message and sending the execution success message to the message table includes: The execution success message is obtained by executing the first execution logic, and the first database is operated on according to the execution success message; The successful execution message is sent to the message table.

4. A transaction execution method, characterized in that, Executed by the second node in the transaction execution system, the second node having a second database, including: The execution success message is obtained from the first queue. The execution success message is generated by the first node in the transaction execution system after operating on the first database of the first node according to the target transaction. The execution success message is also used to write to the message table of the first node and set the status of the execution success message in the message table to be sent. Based on the successful execution message, perform operations on the second database and obtain a feedback message; The feedback message is sent to the second queue so that the first node can change the status of the execution success message in the message according to the feedback message in the second queue, and manage the target transaction according to the status of the execution success message in the message table, including: modifying the status of the execution success message in the message table to "sent" according to the feedback message; resending the execution success messages in the message table with the status of "sent" to the first queue in a polling manner, so that the second node can operate on the second database according to the resent execution success message, and send the feedback message to the second queue.

5. The method as described in claim 4, characterized in that, Also includes: When the execution success message fails to be received from the first queue, a resent execution success message is received from the first queue. The resent execution success message is sent by the first node to the first queue according to the status of the execution success message in its local message table. The second database is operated on based on the resent execution success message to obtain the feedback message; The feedback message is sent to the second queue so that the first node in the transaction execution system can manage the status of the execution success message based on the feedback message in the second queue.

6. The method as described in claim 4, characterized in that, Also includes: When the operation on the second database fails according to the execution success message, a resent execution success message is obtained from the first queue. The resent execution success message is resent by the first node to the first queue according to the status of the execution success message in the local message table. The second database is operated on based on the resent execution success message to obtain the feedback message; The feedback message is sent to the second queue so that the first node in the transaction execution system can manage the status of the execution success message based on the feedback message in the second queue.

7. A transaction execution system, characterized in that, include: The first node includes a first database, and the first node is configured to receive the execution instruction of the target transaction; The system operates on the first database according to the target transaction, obtains an execution success message, sends the execution success message to a message table, and sets the status of the execution success message in the message table to "sending". The system then sends the execution success message to a first queue and listens for feedback messages in a second queue. The status of the execution success message in the message table is changed according to the feedback message to manage the target transaction based on the status of the execution success message in the message table. This includes: modifying the status of the execution success message in the message table to "sent" according to the feedback message; resending the execution success messages in the message table with the status "sent" to the first queue through a polling method, so that the second node can operate on the second database according to the resent execution success message and send the feedback message to the second queue. The second node includes a second database, which is configured to listen for the execution success message from the first queue; perform operations on the second database based on the execution success message to obtain a feedback message; and send the feedback message to the second queue.

8. An electronic device, characterized in that, include: One or more processors; Storage device for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1-6.

9. A computer-readable medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1-6.

Citation Information

Patent Citations

  • Queue message uniformity implementing method and device, equipment and storage medium

    CN108009027A

  • Order processing method based on micro-service e-commerce system

    CN110888893A