WO2020108325A1 - 事务处理方法、装置和设备 - Google Patents

事务处理方法、装置和设备 Download PDF

Info

Publication number
WO2020108325A1
WO2020108325A1 PCT/CN2019/118680 CN2019118680W WO2020108325A1 WO 2020108325 A1 WO2020108325 A1 WO 2020108325A1 CN 2019118680 W CN2019118680 W CN 2019118680W WO 2020108325 A1 WO2020108325 A1 WO 2020108325A1
Authority
WO
WIPO (PCT)
Prior art keywords
transaction
message
message queue
global
queue middleware
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Ceased
Application number
PCT/CN2019/118680
Other languages
English (en)
French (fr)
Inventor
杜恒
冯嘉
厉启鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Alibaba Group Holding Ltd
Original Assignee
Alibaba Group Holding Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Publication of WO2020108325A1 publication Critical patent/WO2020108325A1/zh
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • H04L67/566Grouping or aggregating service requests, e.g. for unified processing
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • H04L67/568Storing data temporarily at an intermediate stage, e.g. caching

Definitions

  • This application relates to the field of transaction processing technology, and in particular to a transaction processing method, device, electronic device, and storage device. This application also relates to another transaction processing method, device, electronic device, and storage device.
  • the transaction processing solution under the existing technology needs to have a separately deployed coordinator responsible for promoting the entire distributed transaction.
  • the mode of using the coordinator to promote distributed transactions is basically to adopt synchronous advance There is a performance bottleneck in the transaction mode.
  • This application provides a transaction process to solve the problem in the existing transaction processing method that requires a separate set of coordinators to cause the solution to have external dependencies; at the same time, it solves the problem that the performance cannot be improved due to synchronously advancing transactions;
  • the existing distributed transaction solution programming model has a relatively heavy problem; in addition, since this application relies on message queue middleware, it provides a highly available solution.
  • This application provides a transaction processing method, including:
  • the message queue middleware obtains the global transaction identifier of the transaction
  • the message queue middleware receives the transaction processing message for the global transaction identifier sent by the transaction initiator;
  • the message queue middleware performs transaction processing according to the transaction processing message, and promotes transaction execution.
  • the transaction processing message includes a transaction submission message
  • the message queue middleware performs transaction processing according to the transaction processing message, including:
  • the message queue middleware performs transaction submission processing according to the transaction submission message.
  • the message queue middleware performs transaction submission processing according to the transaction submission message, including:
  • the message queue middleware marks the successful execution of the transaction corresponding to the global transaction identifier according to the transaction submission message
  • the message queue middleware deletes the transaction record corresponding to the global transaction identifier.
  • the transaction processing message includes a transaction rollback message
  • the message queue middleware performs transaction processing according to the transaction processing message, including:
  • the message queue middleware performs transaction rollback processing according to the transaction rollback message.
  • the message queue middleware performs transaction rollback processing according to the transaction rollback message, including:
  • the message queue middleware rolls back the message according to the transaction, and finds the sub-transaction of the transaction that has been successfully executed;
  • the message queue middleware sends a rollback message to the service corresponding to the successfully executed sub-transaction.
  • Optional also includes:
  • the message queue middleware receives the execution result message of the sub-transaction sent by the transaction initiator;
  • the execution result message includes: the execution result of the sub-transaction, the sub-transaction identifier, and the global transaction identifier;
  • Optional also includes:
  • Message queue middleware scans timeout transactions that have not been committed or rolled back within a preset time
  • the message queue middleware sends a check-back request message to the transaction initiator corresponding to the timeout transaction.
  • the check-back request includes the identifier of the sub-transaction that has been successfully executed and the global transaction identifier of the corresponding transaction.
  • Optional also includes:
  • the message queue middleware receives the transaction rollback message or the transaction commit message sent by the transaction initiator corresponding to the timeout transaction.
  • Optional also includes:
  • Message queue middleware scans timeout transactions that have not been committed or rolled back within a preset time
  • the message queue middleware sends a transaction rollback message to the service of the successfully executed sub-transaction corresponding to the timeout transaction.
  • the message queue middleware obtaining the global transaction identifier of the transaction includes:
  • the message queue middleware obtains the prepared message sent by the transaction initiator of the transaction
  • the message queue middleware returns the global transaction identifier of the transaction to the transaction initiator according to the preparation message.
  • the message queue middleware obtaining the global transaction identifier of the transaction includes:
  • the message queue middleware obtains the global transaction identifier of the transaction sent by the transaction initiator.
  • This application also provides a transaction processing method, including:
  • the method further includes: sending the execution result message of the sub-transaction of the transaction to the message queue middleware; the execution result message includes: the execution result of the sub-transaction, the sub-transaction identifier, and the global transaction identifier.
  • the transaction processing message includes a transaction submission message
  • the sending of the transaction processing message for the global transaction identifier to the message queue middleware includes:
  • a transaction commit message for the global transaction identifier is sent to the message queue middleware.
  • the transaction processing message includes a transaction rollback message
  • the sending of the transaction processing message for the global transaction identifier to the message queue middleware includes:
  • Optional also includes:
  • the check-back request includes: the ID of the sub-transaction that has been successfully executed and the global transaction ID of the transaction;
  • Optional also includes:
  • Optional also includes:
  • the obtaining the global transaction identifier of the transaction includes:
  • the obtaining the global transaction identifier of the transaction includes:
  • the transaction initiator generates the global transaction identifier of the transaction
  • the method also includes:
  • This application also provides a transaction processing device, including:
  • a global transaction identification obtaining unit used for the message queue middleware to obtain the global transaction identification of the transaction
  • a transaction processing message receiving unit used for message queue middleware to receive the transaction processing message sent by the transaction initiator for the global transaction identifier
  • the transaction processing unit is used for the message queue middleware to perform transaction processing according to the transaction processing message and promote transaction execution.
  • This application also provides an electronic device, including:
  • the memory is used to store the program of the transaction processing method. After the device is powered on and runs the program of the transaction processing method through the processor, the following steps are performed:
  • the message queue middleware obtains the global transaction identifier of the transaction
  • the message queue middleware receives the transaction processing message for the global transaction identifier sent by the transaction initiator;
  • the message queue middleware performs transaction processing according to the transaction processing message, and promotes transaction execution.
  • the present application also provides a storage device that stores a program of a transaction processing method, which is executed by a processor and performs the following steps:
  • the message queue middleware obtains the global transaction identifier of the transaction
  • the message queue middleware receives the transaction processing message for the global transaction identifier sent by the transaction initiator;
  • the message queue middleware performs transaction processing according to the transaction processing message, and promotes transaction execution.
  • This application also provides a transaction processing device, including:
  • a global transaction identifier obtaining unit used to obtain the global transaction identifier of the transaction
  • a transaction processing message sending unit configured to send a transaction processing message for the global transaction identifier to the message queue middleware.
  • This application also provides an electronic device, including:
  • the memory is used to store the program of the transaction processing method. After the device is powered on and runs the program of the transaction processing method through the processor, the following steps are performed:
  • the present application also provides a storage device that stores a program of a transaction processing method, which is executed by a processor and performs the following steps:
  • the present application provides a transaction processing method, apparatus, electronic equipment, and storage device, obtains a global transaction identifier of a transaction through a message queue middleware, and receives a transaction processing message sent by the transaction initiator for the global transaction identifier; and according to The transaction processing message performs transaction processing.
  • This application uses message queue middleware as a coordinator, and there is no need to separately deploy a set of coordinators, which avoids the external dependency problem of deploying a coordinator separately; at the same time, this application is to promote transaction execution by message queue middleware, because message queues have asynchronous solutions Coupling feature, so that the transaction execution process is performed asynchronously, which improves the performance of the system; at the same time solves the problem of the current distributed transaction solution programming model; in addition, because this application relies on message queue middleware, it provides Highly available solutions.
  • FIG. 1 is a flowchart of a transaction processing method provided by the first embodiment of the present application.
  • FIG. 2 is a schematic diagram of a scenario of transaction submission processing provided by the first embodiment of the present application.
  • FIG. 3 is a schematic diagram of a scenario of transaction rollback processing provided by the first embodiment of the present application.
  • FIG. 4 is a schematic diagram of a scenario of transaction timeout processing provided by the first embodiment of the present application.
  • FIG. 5 is a schematic diagram of another scenario of transaction timeout processing provided by the first embodiment of the present application.
  • FIG. 6 is a flowchart of a transaction processing method provided by a second embodiment of the present application.
  • FIG. 7 is a schematic diagram of a transaction processing apparatus provided in a third embodiment of the present application.
  • FIG. 8 is a schematic diagram of an electronic device provided by a fourth embodiment of the present application.
  • FIG. 9 is a schematic diagram of a transaction processing apparatus according to a sixth embodiment of the present application.
  • FIG. 10 is a schematic diagram of an electronic device provided by a seventh embodiment of the present application.
  • the first embodiment of the present application provides a transaction processing method, which will be described in detail below with reference to FIGS. 1, 2, 2, 3, 4 and 5.
  • step S101 the message queue middleware obtains the preparation message sent by the transaction initiator of the transaction.
  • the message queue middleware is an important component in a distributed system, and mainly solves the problems of application coupling, asynchronous messaging, traffic shaving, and the like.
  • the message queue provides an asynchronous communication mechanism.
  • the records in each queue contain detailed data, including the time of occurrence, the type of input device, and specific input parameters.
  • the sender and receiver of the message do not need to be with the message queue at the same time. Interaction.
  • the message will be kept in the queue until the recipient retrieves it.
  • MQ message queue is a kind of message queue middleware.
  • the transaction may refer to a distributed transaction.
  • Distributed transaction means that the participants of the transaction, the server supporting the transaction, the resource server and the transaction manager are located on different nodes of different distributed systems.
  • a transaction includes at least one sub-transaction.
  • a transaction can be divided into multiple sub-transactions according to business requirements, and each sub-transaction can correspond to a data operation.
  • Each sub-transaction can be executed by a different service, and the service that executes different sub-transactions can run on the same node or on different nodes. For example, when a user purchases a certain commodity, it can be regarded as a distributed transaction, which includes three processes, which can be abstracted into three sub-transactions: order deduction, inventory reduction, and order information update.
  • the transaction initiator may refer to the party that initiates the transaction. For example, when a user purchases a certain commodity, the order service is the transaction initiator.
  • step 1 the transaction initiator sends a prepare message to the MQ message middleware, and the message queue middleware receives the preparation message sent by the transaction initiator of the transaction.
  • step S102 the message queue middleware returns the global transaction identifier of the transaction to the transaction initiator according to the preparation message.
  • the MQ message queue returns the transaction's global transaction identifier (msgid) to the transaction initiator for the MQ message queue to uniquely identify the transaction.
  • the message queue middleware obtains the global transaction identifier of the transaction.
  • the global transaction identifier generated by the message queue middleware can guarantee global uniqueness, and once the global transaction identifier is generated and returned To the initiator of the transaction, it means that the transaction has been recorded in the message queue middleware.
  • the message queue middleware can also obtain the global transaction identifier of the transaction in the following manner: .
  • This method is the global transaction identifier of the transaction generated by the transaction initiator.
  • the transaction initiator can also be initiated by the transaction initiator if it can generate a globally unique transaction identifier. It is necessary to ensure that the generated global transaction identifier Write to the message queue middleware.
  • step S103 the message queue middleware receives the transaction processing message for the global transaction identifier sent by the transaction initiator.
  • the transaction processing messages include transaction commit messages and transaction rollback messages.
  • the transaction initiator can send a transaction commit message to the message queue middleware after all the sub-transactions of the transaction are executed successfully; when a sub-transaction of the transaction fails, the transaction initiator sends a transaction rollback message to the message queue middleware.
  • step S104 the message queue middleware performs transaction processing according to the transaction processing message to promote transaction execution.
  • the message queue middleware When the transaction processing message is a transaction submission message, the message queue middleware performs transaction processing according to the transaction processing message, including: the message queue middleware performs transaction submission processing according to the transaction submission message.
  • the message queue middleware performs transaction submission processing according to the transaction submission message, including:
  • the message queue middleware marks the successful execution of the transaction corresponding to the global transaction identifier according to the transaction submission message
  • the message queue middleware deletes the transaction record corresponding to the global transaction identifier.
  • step 9 after all the sub-transactions included in the transaction have been successfully executed, the transaction initiator can send a transaction commit message to the MQ message queue.
  • the transaction commit message contains the global transaction identifier of the transaction, and the MQ message queue receives the transaction After the message is submitted, the transaction corresponding to the global transaction identifier is marked as successfully executed, and the transaction record corresponding to the global transaction identifier is deleted.
  • the message queue middleware When the transaction processing message is a transaction rollback message, the message queue middleware performs transaction processing according to the transaction processing message, including: the message queue middleware performs transaction rollback processing according to the transaction rollback message.
  • the message queue middleware performs transaction rollback processing according to the transaction rollback message, including:
  • the message queue middleware rolls back the message according to the transaction, and finds the sub-transaction of the transaction that has been successfully executed;
  • the message queue middleware sends a rollback message to the service corresponding to the successfully executed sub-transaction.
  • the sub-transactions corresponding to Service1 (Service 1), Service2 (Service 2), and Service3 (Service 3) are sub-transaction 1, sub-transaction 2, and sub-transaction 3, respectively.
  • the transaction initiator sends a transaction rollback message (rollback) to the MQ message queue.
  • the MQ message queue finds the sub-transactions of the transaction that have been successfully executed, and it is found that sub-transaction 1 and sub-transaction 2 have been executed Successful, in step 9, the MQ message queue sends rollback messages to Service1 and Service2 respectively, and Service1 and Service2 perform the rollback of sub-transaction 1 and sub-transaction 2.
  • sub-transaction 1, sub-transaction 2, and sub-transaction 3 are: order deduction, delete inventory, update order information, order deduction, delete inventory two sub-transactions have been successfully executed, MQ message in step 9
  • the queue sends rollback messages to the order deduction service and the delete inventory service respectively.
  • the order deduction service performs the rollback of sub-transaction 1 and the delete inventory service performs the rollback of sub-transaction 2.
  • the transaction initiator sends the transaction rollback message to the message queue middleware according to the execution of the sub-transaction, and then the message queue middleware sends the rollback message to the corresponding service of the sub-transaction that has been successfully executed. Rollback, to ensure the consistency of the transaction.
  • the message queue middleware can also receive the execution result message of the sub-transaction sent by the transaction initiator;
  • the execution result message includes: the execution result of the sub-transaction, the sub-transaction identifier, and the global transaction identifier;
  • step 4 the transaction initiator sends the transaction ID tx1 of the successfully executed sub-transaction 1, the execution status (OK) of the sub-transaction 1 and the global transaction msgid to the MQ message queue, and the transaction is initiated
  • the party sends the transaction ID tx2 of the successfully executed sub-transaction 2, the execution status (OK) of the sub-transaction 2 and the global transaction msgid to the MQ message queue.
  • the MQ message queue After receiving the above flag, the MQ message queue will successfully execute the transaction of the sub-transaction
  • the identifiers tx1 and tx2 are stored in the corresponding transaction records of the global transaction identifier, so as to associate the transaction identifier of the successfully executed sub-transaction with the global transaction identifier.
  • the MQ message queue can find the transaction of the successfully executed sub-transaction according to the global transaction identifier Logo. Since the MQ message queue contains multiple server nodes and has high availability, the above-mentioned successfully executed sub-transactions can be stored in multiple server nodes. When a server node is down, other server nodes are still available.
  • the message queue middleware can also scan timeout transactions that have not been committed or rolled back within a preset time For example, you can scan the timeout transactions that are not committed or rolled back within a preset time at a certain time interval.
  • the preset time can be determined according to the actual business situation, for example, it can be set to 2 seconds.
  • the first method is: the message queue middleware sends a check-back request message to the transaction initiator corresponding to the timeout transaction, where the check-back request may include: The identifier of the successfully executed sub-transaction and the global transaction identifier of the corresponding transaction.
  • the purpose is for the transaction initiator corresponding to the timeout transaction to decide whether to commit or rollback the transaction according to the execution status of the transaction.
  • the transaction initiator of a timeout transaction sends a transaction rollback message or a transaction commit message to the message queue middleware according to the review request message.
  • the message queue middleware receives the transaction rollback message or transaction commit message sent by the transaction initiator corresponding to the timeout transaction.
  • the message queue middleware sends a check-back request message to the transaction initiator corresponding to the timeout transaction.
  • the check-back request message includes: Check: msgid: tx1, tx2.
  • the transaction initiator sends the transaction rollback message or transaction commit message to the MQ message queue; if the transaction initiator cannot accurately determine the status of the transaction execution, it can send (unknown) unknown to the MQ message queue Message, after receiving the unknown message, the MQ message queue can delay a period of time and send a check-back request message to the transaction initiator corresponding to the timeout transaction again.
  • the second method is: the message queue middleware sends a transaction rollback message to the service of the successfully executed sub-transaction corresponding to the timeout transaction. In this way, the message queue middleware directly sends a rollback command to the service of the sub-transaction of the timeout transaction.
  • step 7 the message queue middleware sends a transaction rollback message to the service 1 of the successfully executed subtransaction 1 corresponding to the timeout transaction, and the service 1 performs the transaction rollback operation on the subtransaction 1; in step In 8, the message queue middleware sends a transaction rollback message to the service 2 of the successfully executed subtransaction 2 corresponding to the timeout transaction, and the service 2 performs the transaction rollback operation on the subtransaction 2.
  • the first embodiment of the present application builds a minimalist distributed transaction solution based on message queue middleware.
  • the message queue service itself acts as a natural coordinator to promote transaction execution. Due to the asynchronous decoupling feature of the message queue, the transaction execution process is performed in an asynchronous manner to improve performance; the transaction initiator sends the transaction rollback message to the message queue middleware according to the execution of the subtransaction, and then the message queue middle
  • the software sends the rollback messages to the services corresponding to the successfully executed sub-transactions, which implements the rollback of the complete transaction and ensures the consistency of the transaction; further, the message queue middleware scan is not submitted or returned within a preset time
  • the transaction initiator of the time-out transaction decides how to handle the time-out transaction, which avoids the problem that the transaction initiator hangs and causes the transaction to not advance, and also avoids the problem of rough rollback immediately after the transaction times out.
  • the second embodiment of the present application provides a transaction processing method, and the execution subject of the second embodiment of the present application is the transaction initiator. Detailed description will be given below with reference to FIGS. 2, 3, 4, 5 and 6.
  • step S601 a preparation message that triggers the message queue middleware to generate the global transaction identifier of the transaction is sent to the message queue middleware.
  • the message queue middleware is an important component in a distributed system, and mainly solves the problems of application coupling, asynchronous messaging, traffic shaving, and the like.
  • the message queue provides an asynchronous communication mechanism.
  • the records in each queue contain detailed data, including the time of occurrence, the type of input device, and specific input parameters.
  • the sender and receiver of the message do not need to be with the message queue at the same time. Interaction.
  • the message will be kept in the queue until the receiver retrieves it.
  • MQ message queue is a kind of message queue middleware.
  • the transaction may refer to a distributed transaction.
  • Distributed transaction means that the participants of the transaction, the server supporting the transaction, the resource server and the transaction manager are located on different nodes of different distributed systems.
  • a transaction includes at least one sub-transaction.
  • a transaction can be divided into multiple sub-transactions according to business requirements, and each sub-transaction can correspond to a data operation.
  • Each sub-transaction can be executed by a different service, and the service that executes different sub-transactions can run on the same node or on different nodes. For example, when a user purchases a certain commodity, it can be regarded as a distributed transaction, which includes three processes, which can be abstracted into three sub-transactions: order deduction, inventory reduction, and order information update.
  • the transaction initiator may refer to the party that initiates the transaction. For example, when a user purchases a certain commodity, the order service is the transaction initiator.
  • step 1 the transaction initiator sends a prepare message to the MQ message middleware for the purpose of registering the transaction to the MQ message queue to obtain the transaction's global transaction identifier for use in The MQ message queue uniquely identifies the transaction.
  • step S602 the global transaction identifier of the transaction returned by the message queue middleware is received.
  • the MQ message queue returns the global transaction identifier (msgid) of the transaction to the transaction initiator, and the transaction initiator receives the global transaction identifier of the transaction returned by the MQ message queue.
  • the transaction initiator obtains the global transaction identifier of the transaction.
  • This method is a global transaction identifier generated by the message queue middleware, which can ensure global uniqueness, and once the global transaction identifier is generated and returned to The initiator of the transaction indicates that the transaction has been recorded in the message queue middleware.
  • the transaction initiator can also obtain the global transaction identifier of the transaction in the following manner: the transaction initiator generates the global transaction identifier of the transaction; this method is caused by the transaction The global transaction identifier of the transaction generated by the initiator.
  • the transaction initiator can also be initiated by the transaction initiator if it can generate a globally unique transaction identifier. It is necessary to ensure that the generated global transaction identifier is written into the middle of the message queue File. In this way, the method further includes sending the global transaction identifier of the transaction to the message queue middleware.
  • step S603 a transaction processing message for the global transaction identifier is sent to the message queue middleware.
  • the transaction processing messages include transaction commit messages and transaction rollback messages.
  • the transaction initiator may also send the execution result message of the sub-transaction of the transaction to the message queue middleware; the execution result message includes: the execution result of the sub-transaction, the sub-transaction identifier, and the global transaction identifier.
  • the transaction initiator may only send the successfully executed sub-transaction execution result message to the message queue middleware. The purpose is to cache it by the message queue middleware for use when the transaction is rolled back. Because the message queue middleware contains multiple server nodes and has high availability, the execution result message of the successful execution can be stored in multiple server nodes. When one server node is down, other server nodes are still available.
  • step 4 the transaction initiator sends the transaction ID tx1 of the successfully executed sub-transaction 1, the execution status (OK) of the sub-transaction 1 and the global transaction msgid to the MQ message queue.
  • step 6 the transaction initiator sends the transaction ID tx2 of the successfully executed sub-transaction 2, the execution status (OK) of the sub-transaction 2, and the global transaction msgid to the MQ message queue.
  • a transaction commit message for the global transaction identifier is sent to the message queue middleware.
  • step 9 after all the sub-transactions included in the transaction have been successfully executed, the transaction initiator can send a transaction commit message to the MQ message queue.
  • the transaction commit message contains the global transaction identifier of the transaction, and the MQ message queue receives the transaction After the message is submitted, the transaction corresponding to the global transaction identifier is marked as successfully executed, and the transaction record corresponding to the global transaction identifier is deleted.
  • the sub-transactions corresponding to Service1 (Service 1), Service2 (Service 2), and Service3 (Service 3) are sub-transaction 1, sub-transaction 2, and sub-transaction 3, respectively.
  • the transaction initiator sends the transaction rollback message (rollback) to the MQ message queue.
  • the transaction initiator can also receive the review request message sent by the message queue middleware; the review request includes: the ID of the sub-transaction that has been successfully executed and the global transaction ID of the transaction; after receiving the review request message, according to The check-back request message sends a transaction commit message or a transaction rollback message to the message middleware.
  • the message queue middleware sends a check-back request message to the transaction initiator corresponding to the timeout transaction.
  • the check-back request message includes: Check: msgid: tx1, tx2.
  • the transaction initiator sends the transaction rollback message or transaction commit message to the MQ message queue; if the transaction initiator cannot accurately determine the status of the transaction execution, it can send (unknown) unknown to the MQ message queue Message, after receiving the unknown message, the MQ message queue can delay a period of time and send a check-back request message to the transaction initiator corresponding to the timeout transaction again.
  • the transaction initiator can also remotely call the service corresponding to the sub-transaction of the transaction, and the service corresponding to the sub-transaction executes the sub-transaction.
  • the transaction initiator may also receive the execution result of the sub-transaction returned by the service corresponding to the sub-transaction.
  • the transaction initiator remotely calls service 1 corresponding to sub-transaction 1, service 2 corresponding to sub-transaction 2, and after execution of service 1 and service 2 is completed, the execution result of the sub-transaction is returned. To the initiator of the transaction.
  • the second embodiment of the present application has the following advantages: 1. Submitting through two stages of the message (preparation stage and commit/rollback two stages) Consistent mechanism for solving local transaction execution and sending transaction messages, and this mechanism only depends on the storage mechanism of the message queue itself, and does not introduce external dependencies such as databases. 2. A mechanism for completing the storage of complete transaction state in the form of messages through the message queue service and advancing the transaction, and a mechanism for advancing the transaction for rollback in a message when rollback is required. 3.
  • FIG. 2 shows an interactive process in which a message queue middleware and a transaction initiator perform a transaction submission operation.
  • step 1 the transaction initiator sends a prepare message to the MQ message middleware, and the message queue middleware receives the preparation message sent by the transaction initiator of the transaction;
  • step 2 the MQ message queue returns the global transaction identifier (msgid) of the transaction to the transaction initiator;
  • step 3 the transaction initiator remotely calls service 1 corresponding to sub-transaction 1. After service 1 successfully executes sub-transaction 1, it generates sub-transaction identifier id1:tx1 and returns the execution result of sub-transaction 1 to the transaction initiator;
  • step 4 the transaction initiator sends the transaction ID tx1 of the successfully executed sub-transaction 1, the execution status (OK) of the sub-transaction 1 and the global transaction msgid to the MQ message queue;
  • step 5 the transaction initiator remotely calls the service 2 corresponding to the sub-transaction 2 and after the service 2 corresponding to the sub-transaction 2 executes the sub-transaction 2 successfully, the sub-transaction identifier id2:tx2 is generated and the execution result of the sub-transaction 2 is returned to the transaction Initiator;
  • step 6 the transaction initiator sends the transaction ID tx2 of the successfully executed sub-transaction 2, the execution status (OK) of the sub-transaction 2 and the global transaction msgid to the MQ message queue;
  • step 7 the transaction initiator remotely calls the service 3 corresponding to the sub-transaction 3. After the service 3 corresponding to the sub-transaction 3 executes the sub-transaction 3 successfully, the sub-transaction identifier id3:tx3 is generated, and the execution result of the sub-transaction 3 is returned to the transaction Initiator;
  • step 8 the transaction initiator sends the transaction ID tx3 of the successfully executed sub-transaction 3, the execution status (OK) of the sub-transaction 3, and the global transaction msgid to the MQ message queue;
  • step 9 after all the sub-transactions included in the transaction have been successfully executed, the transaction initiator can send a transaction commit message to the MQ message queue.
  • the transaction commit message contains the global transaction ID of the transaction.
  • the MQ message queue marks the global The transaction corresponding to the transaction ID is successfully executed, and the transaction record corresponding to the global transaction ID is deleted.
  • FIG. 3 it shows an interaction process of a message queue middleware and a transaction initiator performing a transaction rollback operation.
  • step 1 the transaction initiator sends a prepare message to the MQ message middleware, and the message queue middleware receives the preparation message sent by the transaction initiator of the transaction;
  • step 2 the MQ message queue returns the global transaction identifier (msgid) of the transaction to the transaction initiator;
  • step 3 the transaction initiator remotely calls service 1 corresponding to sub-transaction 1. After service 1 successfully executes sub-transaction 1, it generates sub-transaction identifier id1:tx1 and returns the execution result of sub-transaction 1 to the transaction initiator;
  • step 4 the transaction initiator sends the transaction ID tx1 of the successfully executed sub-transaction 1, the execution status (OK) of the sub-transaction 1 and the global transaction msgid to the MQ message queue;
  • step 5 the transaction initiator remotely calls the service 2 corresponding to the sub-transaction 2 and after the service 2 corresponding to the sub-transaction 2 executes the sub-transaction 2 successfully, the sub-transaction identifier id2:tx2 is generated and the execution result of the sub-transaction 2 is returned to the transaction Initiator;
  • step 6 the transaction initiator sends the transaction ID tx2 of the successfully executed sub-transaction 2, the execution status (OK) of the sub-transaction 2 and the global transaction msgid to the MQ message queue;
  • step 7 the transaction initiator remotely calls the service 3 corresponding to the sub-transaction 3, the execution of the sub-transaction 3 fails, and the service 3 returns the execution result of the sub-transaction 3 to the transaction initiator;
  • step 8 the transaction initiator sends a transaction rollback message (rollback) to the MQ message queue.
  • the MQ message queue looks up the sub-transactions of the transaction that have been successfully executed, and finds that sub-transaction 1 and sub-transaction 2 have been successfully executed;
  • step 9 the MQ message queue sends rollback messages to Service1, and Service1 performs the rollback of sub-transaction 1.
  • step 10 the MQ message queue sends rollback messages to Service2, and Service2 performs the rollback of subtransaction 2.
  • FIG. 4 shows an interactive process of a message queue middleware and a transaction initiator performing a transaction review operation.
  • step 1 the transaction initiator sends a prepare message to the MQ message middleware, and the message queue middleware receives the preparation message sent by the transaction initiator of the transaction;
  • step 2 the MQ message queue returns the global transaction identifier (msgid) of the transaction to the transaction initiator;
  • step 3 the transaction initiator remotely calls service 1 corresponding to sub-transaction 1. After service 1 successfully executes sub-transaction 1, it generates sub-transaction identifier id1:tx1 and returns the execution result of sub-transaction 1 to the transaction initiator;
  • step 4 the transaction initiator sends the transaction ID tx1 of the successfully executed sub-transaction 1, the execution status (OK) of the sub-transaction 1 and the global transaction msgid to the MQ message queue;
  • step 5 the transaction initiator remotely calls the service 2 corresponding to the sub-transaction 2 and after the service 2 corresponding to the sub-transaction 2 executes the sub-transaction 2 successfully, the sub-transaction identifier id2:tx2 is generated and the execution result of the sub-transaction 2 is returned to the transaction Initiator;
  • step 6 the transaction initiator sends the transaction ID tx2 of the successfully executed sub-transaction 2, the execution status (OK) of the sub-transaction 2 and the global transaction msgid to the MQ message queue;
  • step 7 the message queue middleware sends a check-back request message to the transaction initiator corresponding to the timeout transaction.
  • the check-back request message includes: Check: msgid: tx1, tx2;
  • step 8 the transaction initiator sends the transaction rollback message or transaction commit message to the MQ message queue; if the transaction initiator cannot accurately determine the status of the transaction execution, it can send (unknown) unknown to the MQ message queue Message, after receiving the unknown message, the MQ message queue can delay a period of time and send a check-back request message to the transaction initiator corresponding to the timeout transaction again.
  • FIG. 5 it shows another interaction process of the message queue middleware and the transaction initiator to perform a transaction review operation.
  • step 1 the transaction initiator sends a prepare message to the MQ message middleware, and the message queue middleware receives the preparation message sent by the transaction initiator of the transaction;
  • step 2 the MQ message queue returns the global transaction identifier (msgid) of the transaction to the transaction initiator;
  • step 3 the transaction initiator remotely calls service 1 corresponding to sub-transaction 1. After service 1 successfully executes sub-transaction 1, it generates sub-transaction identifier id1:tx1 and returns the execution result of sub-transaction 1 to the transaction initiator;
  • step 4 the transaction initiator sends the transaction ID tx1 of the successfully executed sub-transaction 1, the execution status (OK) of the sub-transaction 1 and the global transaction msgid to the MQ message queue;
  • step 5 the transaction initiator remotely calls the service 2 corresponding to the sub-transaction 2 and after the service 2 corresponding to the sub-transaction 2 executes the sub-transaction 2 successfully, the sub-transaction identifier id2:tx2 is generated and the execution result of the sub-transaction 2 is returned to the transaction Initiator;
  • step 6 the transaction initiator sends the transaction ID tx2 of the successfully executed sub-transaction 2, the execution status (OK) of the sub-transaction 2 and the global transaction msgid to the MQ message queue;
  • step 7 the message queue middleware sends a transaction rollback message to the service 1 of the successfully executed subtransaction 1 corresponding to the timeout transaction, and the service 1 performs the transaction rollback operation on the subtransaction 1;
  • step 8 the message queue middleware sends a transaction rollback message to the service 2 of the successfully executed subtransaction 2 corresponding to the timeout transaction, and the service 2 performs the transaction rollback operation on the subtransaction 2.
  • a third embodiment of the present application further provides a transaction processing device.
  • the transaction processing device includes:
  • the global transaction identifier obtaining unit 701 is used for the message queue middleware to return the global transaction identifier of the transaction to the transaction initiator according to the preparation message;
  • a transaction processing message receiving unit 702 configured to receive a transaction processing message for the global transaction identifier sent by the transaction initiator by the message queue middleware;
  • the transaction processing unit 703 is used for the message queue middleware to perform transaction processing according to the transaction processing message and promote transaction execution.
  • the transaction processing message includes a transaction submission message
  • the transaction processing unit includes:
  • the message queue middleware performs transaction submission processing according to the transaction submission message.
  • the transaction processing unit is specifically used for:
  • the message queue middleware marks the successful execution of the transaction corresponding to the global transaction identifier according to the transaction submission message
  • the message queue middleware deletes the transaction record corresponding to the global transaction identifier.
  • the transaction processing message includes a transaction rollback message
  • the message queue middleware performs transaction processing according to the transaction processing message, including:
  • the message queue middleware performs transaction rollback processing according to the transaction rollback message.
  • the transaction processing unit is specifically used for:
  • the message queue middleware rolls back the message according to the transaction, and finds the sub-transaction of the transaction that has been successfully executed;
  • the message queue middleware sends a rollback message to the service corresponding to the successfully executed sub-transaction.
  • the device further includes:
  • the execution result message receiving unit is used for the message queue middleware to receive the execution result message of the sub-transaction sent by the transaction initiator;
  • the execution result message includes: the execution result of the sub-transaction, the sub-transaction identifier and the global transaction identifier ;
  • the execution result message storage unit is configured to store the execution result message of the sub-transaction into the corresponding transaction record of the global transaction identifier.
  • the device further includes:
  • Scan timeout transaction unit used for message queue middleware scanning timeout transactions that are not submitted or rolled back within a preset time
  • the check-back request message sending unit is used for the message queue middleware to send a check-back request message to the transaction initiator corresponding to the timeout transaction.
  • the check-back request includes the identifier of the sub-transaction that has been successfully executed and the global transaction identifier of the corresponding transaction.
  • the device further includes:
  • the message receiving unit is used for the message queue middleware to receive the transaction rollback message or the transaction commit message sent by the transaction initiator corresponding to the timeout transaction.
  • the device further includes:
  • Time-out transaction scanning unit used for message queue middleware to scan time-out transactions that have not been submitted or rolled back within a preset time
  • the transaction rollback message sending unit is used for the message queue middleware to send a transaction rollback message to the service of the successfully executed sub-transaction corresponding to the timeout transaction.
  • the global transaction identifier obtaining unit is specifically used for:
  • the message queue middleware obtains the prepared message sent by the transaction initiator of the transaction
  • the message queue middleware returns the global transaction identifier of the transaction to the transaction initiator according to the preparation message.
  • the global transaction identifier obtaining unit is specifically used for:
  • the message queue middleware obtains the global transaction identifier of the transaction sent by the transaction initiator.
  • the fourth embodiment of the present application further provides an electronic device.
  • the electronic device includes:
  • the memory 802 is used to store the program of the transaction processing method. After the device is powered on and runs the program of the transaction processing method through the processor, the following steps are performed:
  • the message queue middleware obtains the global transaction identifier of the transaction
  • the message queue middleware receives the transaction processing message for the global transaction identifier sent by the transaction initiator;
  • the message queue middleware performs transaction processing according to the transaction processing message, and promotes transaction execution.
  • the transaction processing message includes a transaction submission message
  • the message queue middleware performs transaction processing according to the transaction processing message, including:
  • the message queue middleware performs transaction submission processing according to the transaction submission message.
  • the message queue middleware performs transaction submission processing according to the transaction submission message, including:
  • the message queue middleware marks the successful execution of the transaction corresponding to the global transaction identifier according to the transaction submission message
  • the message queue middleware deletes the transaction record corresponding to the global transaction identifier.
  • the transaction processing message includes a transaction rollback message
  • the message queue middleware performs transaction processing according to the transaction processing message, including:
  • the message queue middleware performs transaction rollback processing according to the transaction rollback message.
  • the message queue middleware performs transaction rollback processing according to the transaction rollback message, including:
  • the message queue middleware rolls back the message according to the transaction, and finds the sub-transaction of the transaction that has been successfully executed;
  • the message queue middleware sends a rollback message to the service corresponding to the successfully executed sub-transaction.
  • the electronic device is also used to perform the following steps:
  • the message queue middleware receives the execution result message of the sub-transaction sent by the transaction initiator;
  • the execution result message includes: the execution result of the sub-transaction, the sub-transaction identifier, and the global transaction identifier;
  • the electronic device is also used to perform the following steps:
  • Message queue middleware scans timeout transactions that have not been committed or rolled back within a preset time
  • the message queue middleware sends a check-back request message to the transaction initiator corresponding to the timeout transaction.
  • the check-back request includes the identifier of the sub-transaction that has been successfully executed and the global transaction identifier of the corresponding transaction.
  • the electronic device is also used to perform the following steps:
  • the message queue middleware receives the transaction rollback message or the transaction commit message sent by the transaction initiator corresponding to the timeout transaction.
  • the electronic device is also used to perform the following steps:
  • Message queue middleware scans timeout transactions that have not been committed or rolled back within a preset time
  • the message queue middleware sends a transaction rollback message to the service of the successfully executed sub-transaction corresponding to the timeout transaction.
  • the message queue middleware obtaining the global transaction identifier of the transaction includes:
  • the message queue middleware obtains the prepared message sent by the transaction initiator of the transaction
  • the message queue middleware returns the global transaction identifier of the transaction to the transaction initiator according to the preparation message.
  • the message queue middleware obtaining the global transaction identifier of the transaction includes:
  • the message queue middleware obtains the global transaction identifier of the transaction sent by the transaction initiator.
  • the fifth embodiment of the present application further provides a storage device that stores a program of the transaction processing method, which is executed by the processor and executes the following step:
  • the message queue middleware obtains the global transaction identifier of the transaction
  • the message queue middleware receives the transaction processing message for the global transaction identifier sent by the transaction initiator;
  • the message queue middleware performs transaction processing according to the transaction processing message, and promotes transaction execution.
  • a sixth embodiment of the present application further provides a transaction processing apparatus.
  • the transaction processing device includes:
  • the transaction message sending unit 902 is used to send the transaction message for the global transaction identifier to the message queue middleware.
  • the device further includes:
  • the execution result message sending unit is used to send the execution result message of the sub-transaction of the transaction to the message queue middleware; the execution result message includes: the execution result of the sub-transaction, the sub-transaction identifier and the global transaction identifier.
  • the transaction processing message includes a transaction submission message
  • the transaction processing message sending unit is specifically used for:
  • a transaction commit message for the global transaction identifier is sent to the message queue middleware.
  • the transaction processing message includes a transaction rollback message
  • the transaction processing message sending unit is specifically used for:
  • the device further includes:
  • the check-back request message receiving unit is used to receive a check-back request message sent by the message queue middleware; the check-back request includes: the ID of the sub-transaction that has been successfully executed and the global transaction ID of the transaction;
  • the processing message sending unit is configured to send a transaction commit message or a transaction rollback message to the message middleware according to the review request message.
  • the device further includes:
  • the sub-transaction service invoking unit is used to remotely call the service corresponding to the sub-transaction of the transaction.
  • the device further includes:
  • the sub-transaction execution result receiving unit is configured to receive the execution result of the sub-transaction returned by the service corresponding to the sub-transaction.
  • the global transaction identifier obtaining unit is specifically used for:
  • the global transaction identifier obtaining unit is specifically used for:
  • the transaction initiator generates the global transaction identifier of the transaction
  • the device also includes: a global transaction identifier sending unit,
  • the seventh embodiment of the present application further provides an electronic device.
  • the electronic device includes:
  • the memory 1002 is used to store the program of the transaction processing method. After the device is powered on and runs the program of the transaction processing method through the processor, the following steps are performed:
  • the electronic device is further configured to perform the following steps: send the execution result message of the sub-transaction of the transaction to the message queue middleware; the execution result message includes: the execution result of the sub-transaction and the sub-transaction identifier And the global transaction identifier.
  • the transaction processing message includes a transaction submission message
  • the sending of the transaction processing message for the global transaction identifier to the message queue middleware includes:
  • a transaction commit message for the global transaction identifier is sent to the message queue middleware.
  • the transaction processing message includes a transaction rollback message
  • the sending of the transaction processing message for the global transaction identifier to the message queue middleware includes:
  • the electronic device is also used to perform the following steps:
  • the check-back request includes: the ID of the sub-transaction that has been successfully executed and the global transaction ID of the transaction;
  • the electronic device is also used to perform the following steps:
  • the electronic device is also used to perform the following steps:
  • the obtaining the global transaction identifier of the transaction includes:
  • the obtaining the global transaction identifier of the transaction includes:
  • the transaction initiator generates the global transaction identifier of the transaction
  • the electronic device is also used to perform the following steps:
  • the eighth embodiment of the present application further provides a storage device storing a program of the transaction processing method, which is executed by the processor and executes the following step:
  • the computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
  • processors CPUs
  • input/output interfaces network interfaces
  • memory volatile and non-volatile memory
  • the memory may include non-permanent memory, random access memory (RAM) and/or non-volatile memory in computer-readable media, such as read only memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
  • RAM random access memory
  • ROM read only memory
  • flash RAM flash random access memory
  • Computer-readable media including permanent and non-permanent, removable and non-removable media, can store information by any method or technology.
  • the information may be computer readable instructions, data structures, modules of programs, or other data.
  • Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, read-only compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, Magnetic tape cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media can be used to store information that can be accessed by computing devices.
  • computer-readable media does not include non-transitory computer-readable media (transitory media), such as modulated data signals and carrier waves.
  • the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Moreover, the present application may take the form of a computer program product implemented on one or more computer usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer usable program code.
  • computer usable storage media including but not limited to disk storage, CD-ROM, optical storage, etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本申请公开了一种事务处理方法、装置和设备。所述方法的一个实施例可以包括:消息队列中间件获得所述事务的全局事务标识;消息队列中间件接收所述事务发起方发送的针对所述全局事务标识的事务处理消息;消息队列中间件根据所述事务处理消息进行事务处理,推进事务执行。以解决现有的事务处理方法中存在的需要单独部署一套协调器导致解决方案存在外部依赖的问题;同时解决同步推进事务导致的性能无法提升的问题;同时解决现有分布式事务解决方案编程模型较重的问题;此外由于本申请依赖消息队列中间件,因此提供了高可用的解决方案。

Description

事务处理方法、装置和设备
本申请要求2018年11月27日递交的申请号为2018114267393、发明名称为“事务处理方法、装置和设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及事务处理技术领域,具体涉及一种事务处理方法、装置、电子设备和存储设备。本申请同时涉及另一种事务处理方法、装置、电子设备和存储设备。
背景技术
在分布式系统中,由于用户数据库或者资源分属于不同的服务,很容易在出现网络故障、服务处理出现问题时导致需要共同协作完成的事务出现不一致状况。
为了保证事务的一致性,现有技术下的事务处理方案,需要存在一个单独部署的协调器负责对整个分布式事务进行推进,采用协调器进行分布式事务推进的方式,基本上是采取同步推进事务的方式,存在性能瓶颈问题。
现有技术下的事务处理方案很难将事务做到异步化,无法提升系统的性能。
发明内容
本申请提供一种事务处理,以解决现有的事务处理方法中存在的需要单独部署一套协调器导致解决方案存在外部依赖的问题;同时解决同步推进事务导致的性能无法提升的问题;同时解决现有分布式事务解决方案编程模型较重的问题;此外由于本申请依赖消息队列中间件,因此提供了高可用的解决方案。
本申请提供一种事务处理方法,包括:
消息队列中间件获得所述事务的全局事务标识;
消息队列中间件接收所述事务发起方发送的针对所述全局事务标识的事务处理消息;
消息队列中间件根据所述事务处理消息进行事务处理,推进事务执行。
可选的,所述事务处理消息,包括事务提交消息;
所述消息队列中间件根据所述事务处理消息进行事务处理,包括:
消息队列中间件根据所述事务提交消息进行事务提交处理。
可选的,所述消息队列中间件根据所述事务提交消息进行事务提交处理,包括:
消息队列中间件根据所述事务提交消息,标记所述全局事务标识对应的事务执行成功;
消息队列中间件删除所述全局事务标识对应的事务记录。
可选的,所述事务处理消息,包括事务回滚消息;
所述消息队列中间件根据所述事务处理消息进行事务处理,包括:
消息队列中间件根据所述事务回滚消息进行事务回滚处理。
可选的,所述消息队列中间件根据所述事务回滚消息进行事务回滚处理,包括:
消息队列中间件根据所述事务回滚消息,查找所述事务的已经成功执行的子事务;
消息队列中间件向所述已经成功执行的子事务对应的服务发送回滚消息。
可选的,还包括:
消息队列中间件接收所述事务发起方发送的子事务的执行结果消息;所述执行结果消息,包括:子事务的执行结果、子事务标识及所述全局事务标识;
将所述子事务的执行结果消息存储到所述全局事务标识的对应的事务记录中。
可选的,还包括:
消息队列中间件扫描在预设时间内未提交或未回滚的超时事务;
消息队列中间件向所述超时事务对应的事务发起方发送回查请求消息。
可选的,所述回查请求中包括:所述已经执行成功的子事务的标识以及对应的事务的全局事务标识。
可选的,还包括:
消息队列中间件接收所述超时事务对应的事务发起方发送的事务回滚消息或者事务提交消息。
可选的,还包括:
消息队列中间件扫描在预设时间内未提交或未回滚的超时事务;
消息队列中间件向所述超时事务对应的执行成功的子事务的服务发送事务回滚消息。
可选的,所述消息队列中间件获得所述事务的全局事务标识,包括:
消息队列中间件获取事务的事务发起方发送的准备消息;
消息队列中间件根据所述准备消息向所述事务发起方返回所述事务的全局事务标识。
可选的,所述消息队列中间件获得所述事务的全局事务标识,包括:
消息队列中间件获取事务发起方发送的所述事务的全局事务标识。
本申请还提供一种事务处理方法,包括:
获得所述事务的全局事务标识;
向所述消息队列中间件发送针对所述全局事务标识的事务处理消息。
可选的,还包括:向消息队列中间件发送所述事务的子事务的执行结果消息;所述执行结果消息,包括:子事务的执行结果、子事务标识及所述全局事务标识。
可选的,所述事务处理消息包括事务提交消息;
所述向所述消息队列中间件发送针对所述全局事务标识的事务处理消息,包括:
当所述分布式事务的子事务全部执行成功时,向所述消息队列中间件发送针对所述全局事务标识的事务提交消息。
可选的,所述事务处理消息包括事务回滚消息;
所述向所述消息队列中间件发送针对所述全局事务标识的事务处理消息,包括:
当所述事务的子事务中有至少一个子事务执行失败时,向所述消息队列中间件发送针对所述全局事务标识的事务回滚信息。
可选的,还包括:
接收消息队列中间件发送的回查请求消息;所述回查请求中包括:已经执行成功的子事务的标识以及事务的全局事务标识;
根据所述回查请求消息,向所述消息中间件发送事务提交消息或事务回滚消息。
可选的,还包括:
远程调用所述事务的子事务对应的服务。
可选的,还包括:
接收所述子事务对应的服务返回的子事务的执行结果。
可选的,所述获得所述事务的全局事务标识,包括:
向消息队列中间件发送触发消息队列中间件生成所述事务的全局事务标识的准备消息;
接收所述消息队列中间件返回的所述事务的全局事务标识。
可选的,所述获得所述事务的全局事务标识,包括:
事务发起方产生所述事务的全局事务标识;
所述方法还包括:
将所述事务的全局事务标识发送给消息队列中间件。
本申请还提供一种事务处理装置,包括:
全局事务标识获得单元,用于消息队列中间件获得所述事务的全局事务标识;
事务处理消息接收单元,用于消息队列中间件接收所述事务发起方发送的针对所述全局事务标识的事务处理消息;
事务处理单元,用于消息队列中间件根据所述事务处理消息进行事务处理,推进事务执行。
本申请还提供一种电子设备,包括:
处理器;以及
存储器,用于存储事务处理方法的程序,该设备通电并通过所述处理器运行该事务处理方法的程序后,执行下述步骤:
消息队列中间件获得所述事务的全局事务标识;
消息队列中间件接收所述事务发起方发送的针对所述全局事务标识的事务处理消息;
消息队列中间件根据所述事务处理消息进行事务处理,推进事务执行。
本申请还提供一种存储设备,存储有事务处理方法的程序,该程序被处理器运行,执行下述步骤:
消息队列中间件获得所述事务的全局事务标识;
消息队列中间件接收所述事务发起方发送的针对所述全局事务标识的事务处理消息;
消息队列中间件根据所述事务处理消息进行事务处理,推进事务执行。
本申请还提供一种事务处理装置,包括:
全局事务标识获得单元,用于获得所述事务的全局事务标识;
事务处理消息发送单元,用于向所述消息队列中间件发送针对所述全局事务标识的事务处理消息。
本申请还提供一种电子设备,包括:
处理器;以及
存储器,用于存储事务处理方法的程序,该设备通电并通过所述处理器运行该事务处理方法的程序后,执行下述步骤:
获得所述事务的全局事务标识;
向所述消息队列中间件发送针对所述全局事务标识的事务处理消息。
本申请还提供一种存储设备,存储有事务处理方法的程序,该程序被处理器运行,执行下述步骤:
获得所述事务的全局事务标识;
向所述消息队列中间件发送针对所述全局事务标识的事务处理消息。
与现有技术相比,本申请具有以下优点:
本申请提供一种事务处理方法、装置、电子设备及存储设备,通过消息队列中间件获得事务的全局事务标识,接收所述事务发起方发送的针对所述全局事务标识的事务处理消息;并根据所述事务处理消息进行事务处理。本申请将消息队列中间件作为协调器,不需要单独部署一套协调器,避免了单独部署协调器存在的外部依赖问题;同时本申请由消息队列中间件推进事务执行,由于消息队列具有异步解耦特性,因此使得事务执行过程均以异步方式进行,从而提升了系统的性能;同时解决现有分布式事务解决方案编程模型较重的问题;此外由于本申请依赖消息队列中间件,因此提供了高可用的解决方案。
附图说明
图1是本申请第一实施例提供的一种事务处理方法的流程图;
图2是本申请第一实施例提供的一种事务提交处理的场景示意图;
图3是本申请第一实施例提供的一种事务回滚处理的场景示意图;
图4是本申请第一实施例提供的一种事务超时处理的场景示意图;
图5是本申请第一实施例提供的另一种事务超时处理的场景示意图;
图6是本申请第二实施例提供的一种事务处理方法的流程图;
图7是本申请第三实施例提供的一种事务处理装置的示意图;
图8是本申请第四实施例提供的一种电子设备的示意图;
图9是本申请第六实施例提供的一种事务处理装置的示意图;
图10是本申请第七实施例提供的一种电子设备的示意图。
具体实施方式
在下面的描述中阐述了很多具体细节以便于充分理解本发明。但是本发明能够以很多不同于在此描述的其它方式来实施,本领域技术人员可以在不违背本发明内涵的情况 下做类似推广,因此本发明不受下面公开的具体实施的限制。
本申请第一实施例提供一种事务处理方法,下面结合图1、图2、图3、图4和图5进行详细说明。
如图1所示,在步骤S101中,消息队列中间件获取事务的事务发起方发送的准备消息。
所述消息队列中间件,是分布式系统中重要的组件,主要解决应用耦合、异步消息、流量削锋等问题。消息队列提供了异步的通信机制,每一个队列中的纪录包含详细说明的数据,包含发生的时间,输入设备的种类,以及特定的输入参数,消息的发送者和接收者不需要同时与消息队列交互。消息会保存在队列中,直到接收者取回此消息。例如,MQ消息队列,为一种消息队列中间件。
所述事务,可以指分布式事务。分布式事务是指事务的参与者、支持事务的服务器、资源服务器以及事务管理器分别位于不同的分布式系统的不同节点之上。一个事务包括至少一个子事务,可以根据业务需求将一个事务划分为多个子事务,每个子事务可以对应一条数据操作。每个子事务可以由不同的服务执行,执行不同子事务的服务可以运行在同一节点上,也可以运行在不同的节点上。例如,用户购买某一个商品,可以看作一个分布式事务,其中包括三个过程,可以抽象为三个子事务:下单扣款、删减库存、更新订单信息。
所述事务发起方,可以指发起事务的一方,例如,用户购买某一个商品时,订单服务为事务发起方。
如图2-图5所示,在步骤1中,事务发起方将准备消息(prepare message)发送给MQ消息中间件,消息队列中间件接收事务的事务发起方发送的准备消息。
如图1所示,在步骤S102中,消息队列中间件根据所述准备消息向所述事务发起方返回所述事务的全局事务标识。
如图2-图5所示,在步骤2中,MQ消息队列向事务发起方返回事务的全局事务标识(msgid),以用于MQ消息队列唯一识别该事务。
通过步骤S101至步骤S102,消息队列中间件获得了所述事务的全局事务标识,此种方式是由消息队列中间件产生的全局事务标识,能够保证全局唯一,且该全局事务标识一旦产生并且返回给事务发起方,则说明该事务已经记录在了消息队列中间件中。
除了采用由消息队列中间件产生全局事务标识的方式外,消息队列中间件还可以采用下列方式获得所述事务的全局事务标识:消息队列中间件获取事务发起方发送的所述 事务的全局事务标识。此种方式是由事务发起方产生的所述事务的全局事务标识,事务发起方在能够做到可以产生全局唯一事务标识的情况下,也可以由事务发起方发起,需要确保生成的全局事务标识写入到消息队列中间件中。
如图1所示,在步骤S103中,消息队列中间件接收所述事务发起方发送的针对所述全局事务标识的事务处理消息。
所述事务处理消息,包括事务提交消息和事务回滚消息。事务发起方在事务的全部子事务执行成功后,可以向消息队列中间件发送事务提交消息;当事务的一个子事务执行失败后,事务发起方向消息队列中间件发送事务回滚消息。
如图1所示,在步骤S104中,消息队列中间件根据所述事务处理消息进行事务处理,推进事务执行。
当事务处理消息为事务提交消息时,所述消息队列中间件根据所述事务处理消息进行事务处理,包括:消息队列中间件根据所述事务提交消息进行事务提交处理。
所述消息队列中间件根据所述事务提交消息进行事务提交处理,包括:
消息队列中间件根据所述事务提交消息,标记所述全局事务标识对应的事务执行成功;
消息队列中间件删除所述全局事务标识对应的事务记录。
如图2所示,在步骤9中,事务包含的全部子事务执行成功后,事务发起方可以向MQ消息队列发送事务提交消息,事务提交消息中包含事务的全局事务标识,MQ消息队列接收事务提交消息后,标记全局事务标识对应的事务执行成功,删除全局事务标识对应的事务记录。
当事务处理消息为事务回滚消息时,所述消息队列中间件根据所述事务处理消息进行事务处理,包括:消息队列中间件根据所述事务回滚消息进行事务回滚处理。
所述消息队列中间件根据所述事务回滚消息进行事务回滚处理,包括:
消息队列中间件根据所述事务回滚消息,查找所述事务的已经成功执行的子事务;
消息队列中间件向所述已经成功执行的子事务对应的服务发送回滚消息。
如图3所示,Service1(服务1)、Service2(服务2)、Service3(服务3)对应的子事务分别为子事务1、子事务2、子事务3,由于步骤7子事务3执行失败,为了保持事务的一致性,步骤8中事务发起方将事务回滚消息(rollback)发送给MQ消息队列,MQ消息队列查找事务的已经成功执行的子事务,查到子事务1和子事务2已经执行成功,步骤9中MQ消息队列将回滚消息分别发送至Service1和Service2,由Service1 和Service2执行子事务1和子事务2的回滚。例如,如果子事务1、子事务2、子事务3分别为:下单扣款、删减库存、更新订单信息,下单扣款、删减库存两个子事务已经执行成功,步骤9中MQ消息队列将回滚消息分别发送至下单扣款服务和删减库存服务,由下单扣款服务执行子事务1的回滚,由删减库存服务执行子事务2的回滚。
通过事务发起方根据子事务的执行情况将事务回滚消息发送给消息队列中间件,再由消息队列中间件将回滚消息分别发送至已经成功执行的子事务对应的服务,实现了完整事务的回滚,保证了事务的一致性。
消息队列中间件还可以接收所述事务发起方发送的子事务的执行结果消息;所述执行结果消息,包括:子事务的执行结果、子事务标识及所述全局事务标识;
将所述子事务的执行结果消息存储到所述全局事务标识的对应的事务记录中。
如图2-图5所示,在步骤4中,事务发起方将成功执行的子事务1的事务标识tx1、子事务1的执行状态(OK)和全局事务msgid发送给MQ消息队列,事务发起方将成功执行的子事务2的事务标识tx2、子事务2的执行状态(OK)和全局事务msgid发送给MQ消息队列,MQ消息队列在收到上述标志后,将成功执行的子事务的事务标识tx1和tx2存储到全局事务标识的对应的事务记录中,从而将成功执行的子事务的事务标识与全局事务标识关联到一起,MQ消息队列可以根据全局事务标识找到成功执行的子事务的事务标识。由于MQ消息队列包含多个服务端节点,具有高可用性,上述成功执行的子事务可以存储到多个服务端节点,当一个服务端节点down后,其他的服务端节点还可用。
为了避免事务发起方挂起导致事务不能推进的问题,也为了避免在事务超时后立即进行粗暴回滚的问题,消息队列中间件还可以扫描在预设时间内未提交或未回滚的超时事务,例如,可以以一定时间间隔扫描在预设时间内未提交或未回滚的超时事务。其中,预设时间可以根据业务实际情况确定,例如可以设置为2秒。
在发现超时事务后,可以采用以下两种方式进行处理:第一种方式为:消息队列中间件向所述超时事务对应的事务发起方发送回查请求消息,其中,回查请求中可以包括:所述已经执行成功的子事务的标识以及对应的事务的全局事务标识。采用此种方式,目的是由超时事务对应的事务发起方根据事务的执行情况决定进行事务提交还是事务回滚处理。超时事务的事务发起方根据回查请求消息向消息队列中间件发送事务回滚消息或者事务提交消息,消息队列中间件接收超时事务对应的事务发起方发送的事务回滚消息或者事务提交消息。
如图4所示,步骤7中,消息队列中间件向超时事务对应的事务发起方发送回查请 求消息,回查请求消息包括:Check:msgid:tx1,tx2。步骤8中,事务发起方将事务回滚消息(rollback)或者事务提交消息(summit)发送给MQ消息队列;如果事务发起方不能准确确定事务执行的状态,可以向MQ消息队列发送(未知)unknown消息,MQ消息队列在收到unknown消息后,可以延迟一段时间再次向发送超时事务对应的事务发起方发送回查请求消息。
第二种方式为:消息队列中间件向超时事务对应的执行成功的子事务的服务发送事务回滚消息。此种方式为由消息队列中间件直接向超时事务的子事务的服务发送回滚命令的方式。
如图5所示,在步骤7中,消息队列中间件向超时事务对应的执行成功的子事务1的服务1发送事务回滚消息,由服务1对子事务1进行事务回滚操作;在步骤8中,消息队列中间件向超时事务对应的执行成功的子事务2的服务2发送事务回滚消息,由服务2对子事务2进行事务回滚操作。
至此,完成了对本申请第一实施例的介绍,本申请第一实施例基于消息队列中间件构建一套极简的分布式事务解决方案,消息队列服务本身作为天生的协调者,推进事务执行,而由于消息队列的异步解耦特性,使得事务执行过程均以异步方式进行,提升性能;通过事务发起方根据子事务的执行情况将事务回滚消息发送给消息队列中间件,再由消息队列中间件将回滚消息分别发送至已经成功执行的子事务对应的服务,实现了完整事务的回滚,保证了事务的一致性;进一步,消息队列中间件扫描在预设时间内未提交或未回滚的超时事务,由超时事务的事务发起方决定对超时事务的处理方式,避免了事务发起方挂起导致事务不能推进的问题,也避免了在事务超时后立即进行粗暴回滚的问题。
与本申请第一实施例相对应,本申请第二实施例提供一种事务处理方法,本申请第二实施例的执行主体为事务发起方。以下结合图2、图3、图4、图5、图6进行详细说明。
如图6所示,在步骤S601中,向消息队列中间件发送触发消息队列中间件生成所述事务的全局事务标识的准备消息。
所述消息队列中间件,是分布式系统中重要的组件,主要解决应用耦合、异步消息、流量削锋等问题。消息队列提供了异步的通信机制,每一个队列中的纪录包含详细说明的数据,包含发生的时间,输入设备的种类,以及特定的输入参数,消息的发送者 和接收者不需要同时与消息队列交互。消息会保存在队列中,直到接收者取回它。例如,MQ消息队列,为一种消息队列中间件。
所述事务,可以指分布式事务。分布式事务是指事务的参与者、支持事务的服务器、资源服务器以及事务管理器分别位于不同的分布式系统的不同节点之上。一个事务包括至少一个子事务,可以根据业务需求将一个事务划分为多个子事务,每个子事务可以对应一条数据操作。每个子事务可以由不同的服务执行,执行不同子事务的服务可以运行在同一节点上,也可以运行在不同的节点上。例如,用户购买某一个商品,可以看作一个分布式事务,其中包括三个过程,可以抽象为三个子事务:下单扣款、删减库存、更新订单信息。
所述事务发起方,可以指发起事务的一方,例如,用户购买某一个商品时,订单服务为事务发起方。
如图2-图5所示,在步骤1中,事务发起方将准备消息(prepare message)发送给MQ消息中间件,目的将事务注册到MQ消息队列,获得事务的全局事务标识,以用于MQ消息队列唯一识别该事务。
如图6所示,在步骤S602中,接收所述消息队列中间件返回的所述事务的全局事务标识。
如图2-图5所示,在步骤2中,MQ消息队列向事务发起方返回事务的全局事务标识(msgid),事务发起方接收MQ消息队列返回的事务的全局事务标识。
通过步骤S601至步骤S602,事务发起方获得了所述事务的全局事务标识,此种方式是由消息队列中间件产生的全局事务标识,能够保证全局唯一,且该全局事务标识一旦产生并且返回给事务发起方,则说明该事务已经记录在了消息队列中间件中。
除了采用由消息队列中间件产生全局事务标识的方式外,事务发起方还可以采用下列方式获得所述事务的全局事务标识:事务发起方产生所述事务的全局事务标识;此种方式是由事务发起方产生的所述事务的全局事务标识,事务发起方在能够做到可以产生全局唯一事务标识的情况下,也可以由事务发起方发起,需要确保生成的全局事务标识写入到消息队列中间件中。采用此种方式,所述方法还包括:将所述事务的全局事务标识发送给消息队列中间件。
如图6所示,在步骤S603中,向所述消息队列中间件发送针对所述全局事务标识的事务处理消息。
所述事务处理消息,包括事务提交消息和事务回滚消息。
事务发起方还可以向消息队列中间件发送事务的子事务的执行结果消息;所述执行结果消息,包括:子事务的执行结果、子事务标识及所述全局事务标识。具体实施时,事务发起方可以只将成功执行的子事务执行结果消息发送给消息队列中间件。目的是由消息队列中间件将其进行缓存,以供在事务回滚时使用。由于消息队列中间件包含多个服务端节点,具有高可用性,上述成功执行的执行结果消息可以存储到多个服务端节点,当一个服务端节点down后,其他的服务端节点还可用。
如图2-图5所示,在步骤4中,事务发起方将成功执行的子事务1的事务标识tx1、子事务1的执行状态(OK)和全局事务msgid发送给MQ消息队列,在步骤6中,事务发起方将成功执行的子事务2的事务标识tx2、子事务2的执行状态(OK)和全局事务msgid发送给MQ消息队列。
当分布式事务的子事务全部执行成功时,向消息队列中间件发送针对全局事务标识的事务提交消息。
如图2所示,在步骤9中,事务包含的全部子事务执行成功后,事务发起方可以向MQ消息队列发送事务提交消息,事务提交消息中包含事务的全局事务标识,MQ消息队列接收事务提交消息后,标记全局事务标识对应的事务执行成功,删除全局事务标识对应的事务记录。
当所述事务的子事务中有至少一个子事务执行失败时,向所述消息队列中间件发送针对所述全局事务标识的事务回滚信息。
如图3所示,Service1(服务1)、Service2(服务2)、Service3(服务3)对应的子事务分别为子事务1、子事务2、子事务3,由于步骤7子事务3执行失败,为了保持事务的一致性,步骤8中事务发起方将事务回滚消息(rollback)发送给MQ消息队列。
事务发起方还可以接收消息队列中间件发送的回查请求消息;所述回查请求中包括:已经执行成功的子事务的标识以及事务的全局事务标识;在收到回查请求消息后,根据所述回查请求消息,向所述消息中间件发送事务提交消息或事务回滚消息。
如图4所示,步骤7中,消息队列中间件向超时事务对应的事务发起方发送回查请求消息,回查请求消息包括:Check:msgid:tx1,tx2。步骤8中,事务发起方将事务回滚消息(rollback)或者事务提交消息(summit)发送给MQ消息队列;如果事务发起方不能准确确定事务执行的状态,可以向MQ消息队列发送(未知)unknown消息,MQ消息队列在收到unknown消息后,可以延迟一段时间再次向发送超时事务对应的事务发起方发送回查请求消息。
事务发起方还可以远程调用所述事务的子事务对应的服务,由子事务对应的服务执行子事务。事务发起方还可以接收所述子事务对应的服务返回的子事务的执行结果。
如图2-图5中的步骤3、5,事务发起方远程调用子事务1对应的服务1,子事务2对应的服务2,服务1和服务2执行完成后,将子事务的执行结果返回给事务发起方。
至此,完成了对本申请第二实施例的介绍,本申请第二实施例与现有技术相比,具有以下优点:1、通过消息的两阶段(准备阶段和提交/回滚两个阶段)提交解决本地事务执行以及发送事务消息的一致性机制,且此种机制仅依赖于消息队列本身存储机制,不会引入外部例如数据库之类的依赖。2.通过消息队列服务以消息形态完成完整事务状态存储并进行事务推进的机制,并且在需要回滚时以消息方式推进事务进行回滚的机制。3.通过可靠消息避免回滚过程以及提交过程中出现的不停重试的机制,以及通过回查机制避免事务超时后粗暴进行回滚的机制,并且在整个回滚处理过程中,均可采用异步方式进行推进提升性能,保证可靠性的机制。
由于上述两个实施例分别以消息队列中间件或者事务发起方单端进行的介绍,为了更清楚地介绍本申请,下面结合图2-图5将上述两端交互在一起进行介绍。
如图2所示,其示出了一种消息队列中间件和事务发起方进行事务提交操作的交互过程。
在步骤1中,事务发起方将准备消息(prepare message)发送给MQ消息中间件,消息队列中间件接收事务的事务发起方发送的准备消息;
在步骤2中,MQ消息队列向事务发起方返回事务的全局事务标识(msgid);
在步骤3中,事务发起方远程调用子事务1对应的服务1,服务1执行子事务1成功后,生成子事务标识id1:tx1,将子事务1的执行结果返回给事务发起方;
在步骤4中,事务发起方将成功执行的子事务1的事务标识tx1、子事务1的执行状态(OK)和全局事务msgid发送给MQ消息队列;
在步骤5中,事务发起方远程调用子事务2对应的服务2,子事务2对应的服务2执行子事务2成功后,生成子事务标识id2:tx2,将子事务2的执行结果返回给事务发起方;
在步骤6中,事务发起方将成功执行的子事务2的事务标识tx2、子事务2的执行状态(OK)和全局事务msgid发送给MQ消息队列;
在步骤7中,事务发起方远程调用子事务3对应的服务3,子事务3对应的服务3执行子事务3成功后,生成子事务标识id3:tx3,将子事务3的执行结果返回给事务发 起方;
在步骤8中,事务发起方将成功执行的子事务3的事务标识tx3、子事务3的执行状态(OK)和全局事务msgid发送给MQ消息队列;
在步骤9中,事务包含的全部子事务执行成功后,事务发起方可以向MQ消息队列发送事务提交消息,事务提交消息中包含事务的全局事务标识,MQ消息队列接收事务提交消息后,标记全局事务标识对应的事务执行成功,删除全局事务标识对应的事务记录。
如图3所示,其示出了一种消息队列中间件和事务发起方进行事务回滚操作的交互过程。
在步骤1中,事务发起方将准备消息(prepare message)发送给MQ消息中间件,消息队列中间件接收事务的事务发起方发送的准备消息;
在步骤2中,MQ消息队列向事务发起方返回事务的全局事务标识(msgid);
在步骤3中,事务发起方远程调用子事务1对应的服务1,服务1执行子事务1成功后,生成子事务标识id1:tx1,将子事务1的执行结果返回给事务发起方;
在步骤4中,事务发起方将成功执行的子事务1的事务标识tx1、子事务1的执行状态(OK)和全局事务msgid发送给MQ消息队列;
在步骤5中,事务发起方远程调用子事务2对应的服务2,子事务2对应的服务2执行子事务2成功后,生成子事务标识id2:tx2,将子事务2的执行结果返回给事务发起方;
在步骤6中,事务发起方将成功执行的子事务2的事务标识tx2、子事务2的执行状态(OK)和全局事务msgid发送给MQ消息队列;
在步骤7中,事务发起方远程调用子事务3对应的服务3,子事务3执行失败,服务3将子事务3的执行结果返回给事务发起方;
在步骤8中,事务发起方将事务回滚消息(rollback)发送给MQ消息队列,MQ消息队列查找事务的已经成功执行的子事务,查到子事务1和子事务2已经执行成功;
在步骤9中,MQ消息队列将回滚消息分别发送至Service1,由Service1执行子事务1的回滚。
在步骤10中,MQ消息队列将回滚消息分别发送至Service2,由Service2执行子事务2的回滚。
如图4所示,其示出了一种消息队列中间件和事务发起方进行事务回查操作的交互过程。
在步骤1中,事务发起方将准备消息(prepare message)发送给MQ消息中间件,消息队列中间件接收事务的事务发起方发送的准备消息;
在步骤2中,MQ消息队列向事务发起方返回事务的全局事务标识(msgid);
在步骤3中,事务发起方远程调用子事务1对应的服务1,服务1执行子事务1成功后,生成子事务标识id1:tx1,将子事务1的执行结果返回给事务发起方;
在步骤4中,事务发起方将成功执行的子事务1的事务标识tx1、子事务1的执行状态(OK)和全局事务msgid发送给MQ消息队列;
在步骤5中,事务发起方远程调用子事务2对应的服务2,子事务2对应的服务2执行子事务2成功后,生成子事务标识id2:tx2,将子事务2的执行结果返回给事务发起方;
在步骤6中,事务发起方将成功执行的子事务2的事务标识tx2、子事务2的执行状态(OK)和全局事务msgid发送给MQ消息队列;
在步骤7中,消息队列中间件向超时事务对应的事务发起方发送回查请求消息,回查请求消息包括:Check:msgid:tx1,tx2;
步骤8中,事务发起方将事务回滚消息(rollback)或者事务提交消息(summit)发送给MQ消息队列;如果事务发起方不能准确确定事务执行的状态,可以向MQ消息队列发送(未知)unknown消息,MQ消息队列在收到unknown消息后,可以延迟一段时间再次向发送超时事务对应的事务发起方发送回查请求消息。
如图5所示,其示出了另一种消息队列中间件和事务发起方进行事务回查操作的交互过程。
在步骤1中,事务发起方将准备消息(prepare message)发送给MQ消息中间件,消息队列中间件接收事务的事务发起方发送的准备消息;
在步骤2中,MQ消息队列向事务发起方返回事务的全局事务标识(msgid);
在步骤3中,事务发起方远程调用子事务1对应的服务1,服务1执行子事务1成功后,生成子事务标识id1:tx1,将子事务1的执行结果返回给事务发起方;
在步骤4中,事务发起方将成功执行的子事务1的事务标识tx1、子事务1的执行状态(OK)和全局事务msgid发送给MQ消息队列;
在步骤5中,事务发起方远程调用子事务2对应的服务2,子事务2对应的服务2执行子事务2成功后,生成子事务标识id2:tx2,将子事务2的执行结果返回给事务发起方;
在步骤6中,事务发起方将成功执行的子事务2的事务标识tx2、子事务2的执行状态(OK)和全局事务msgid发送给MQ消息队列;
在步骤7中,消息队列中间件向超时事务对应的执行成功的子事务1的服务1发送事务回滚消息,由服务1对子事务1进行事务回滚操作;
在步骤8中,消息队列中间件向超时事务对应的执行成功的子事务2的服务2发送事务回滚消息,由服务2对子事务2进行事务回滚操作。
与本申请第一实施例提供的一种事务处理方法相对应的,本申请第三实施例还提供了一种事务处理装置。
如图7所示,所述事务处理装置包括:
全局事务标识获得单元701,用于消息队列中间件根据所述准备消息向所述事务发起方返回所述事务的全局事务标识;
事务处理消息接收单元702,用于消息队列中间件接收所述事务发起方发送的针对所述全局事务标识的事务处理消息;
事务处理单元703,用于消息队列中间件根据所述事务处理消息进行事务处理,推进事务执行。
可选的,所述事务处理消息,包括事务提交消息;
所述事务处理单元,包括:
消息队列中间件根据所述事务提交消息进行事务提交处理。
可选的,所述事务处理单元,具体用于:
消息队列中间件根据所述事务提交消息,标记所述全局事务标识对应的事务执行成功;
消息队列中间件删除所述全局事务标识对应的事务记录。
可选的,所述事务处理消息,包括事务回滚消息;
所述消息队列中间件根据所述事务处理消息进行事务处理,包括:
消息队列中间件根据所述事务回滚消息进行事务回滚处理。
可选的,所述事务处理单元,具体用于:
消息队列中间件根据所述事务回滚消息,查找所述事务的已经成功执行的子事务;
消息队列中间件向所述已经成功执行的子事务对应的服务发送回滚消息。
可选的,所述装置还包括:
执行结果消息接收单元,用于消息队列中间件接收所述事务发起方发送的子事务的 执行结果消息;所述执行结果消息,包括:子事务的执行结果、子事务标识及所述全局事务标识;
执行结果消息存储单元,用于将所述子事务的执行结果消息存储到所述全局事务标识的对应的事务记录中。
可选的,所述装置还包括:
扫描超时事务单元,用于消息队列中间件扫描在预设时间内未提交或未回滚的超时事务;
回查请求消息发送单元,用于消息队列中间件向所述超时事务对应的事务发起方发送回查请求消息。
可选的,所述回查请求中包括:所述已经执行成功的子事务的标识以及对应的事务的全局事务标识。
可选的,所述装置还包括:
消息接收单元,用于消息队列中间件接收所述超时事务对应的事务发起方发送的事务回滚消息或者事务提交消息。
可选的,所述装置还包括:
超时事务扫描单元,用于消息队列中间件扫描在预设时间内未提交或未回滚的超时事务;
事务回滚消息发送单元,用于消息队列中间件向所述超时事务对应的执行成功的子事务的服务发送事务回滚消息。
可选的,所述全局事务标识获得单元,具体用于:
消息队列中间件获取事务的事务发起方发送的准备消息;
消息队列中间件根据所述准备消息向所述事务发起方返回所述事务的全局事务标识。
可选的,所述全局事务标识获得单元,具体用于:
消息队列中间件获取事务发起方发送的所述事务的全局事务标识。
需要说明的是,对于本申请第三实施例提供的事务处理装置的详细描述可以参考对本申请第一实施例的相关描述,这里不再赘述。
与本申请第一实施例提供的一种事务处理方法相对应的,本申请第四实施例还提供了一种电子设备。
如图8所示,所述电子设备包括:
处理器801;以及
存储器802,用于存储事务处理方法的程序,该设备通电并通过所述处理器运行该事务处理方法的程序后,执行下述步骤:
消息队列中间件获得所述事务的全局事务标识;
消息队列中间件接收所述事务发起方发送的针对所述全局事务标识的事务处理消息;
消息队列中间件根据所述事务处理消息进行事务处理,推进事务执行。
可选的,所述事务处理消息,包括事务提交消息;
所述消息队列中间件根据所述事务处理消息进行事务处理,包括:
消息队列中间件根据所述事务提交消息进行事务提交处理。
可选的,所述消息队列中间件根据所述事务提交消息进行事务提交处理,包括:
消息队列中间件根据所述事务提交消息,标记所述全局事务标识对应的事务执行成功;
消息队列中间件删除所述全局事务标识对应的事务记录。
可选的,所述事务处理消息,包括事务回滚消息;
所述消息队列中间件根据所述事务处理消息进行事务处理,包括:
消息队列中间件根据所述事务回滚消息进行事务回滚处理。
可选的,所述消息队列中间件根据所述事务回滚消息进行事务回滚处理,包括:
消息队列中间件根据所述事务回滚消息,查找所述事务的已经成功执行的子事务;
消息队列中间件向所述已经成功执行的子事务对应的服务发送回滚消息。
可选的,所述电子设备还用于执行下述步骤:
消息队列中间件接收所述事务发起方发送的子事务的执行结果消息;所述执行结果消息,包括:子事务的执行结果、子事务标识及所述全局事务标识;
将所述子事务的执行结果消息存储到所述全局事务标识的对应的事务记录中。
可选的,所述电子设备还用于执行下述步骤:
消息队列中间件扫描在预设时间内未提交或未回滚的超时事务;
消息队列中间件向所述超时事务对应的事务发起方发送回查请求消息。
可选的,所述回查请求中包括:所述已经执行成功的子事务的标识以及对应的事务的全局事务标识。
可选的,所述电子设备还用于执行下述步骤:
消息队列中间件接收所述超时事务对应的事务发起方发送的事务回滚消息或者事务提交消息。
可选的,所述电子设备还用于执行下述步骤:
消息队列中间件扫描在预设时间内未提交或未回滚的超时事务;
消息队列中间件向所述超时事务对应的执行成功的子事务的服务发送事务回滚消息。
可选的,所述消息队列中间件获得所述事务的全局事务标识,包括:
消息队列中间件获取事务的事务发起方发送的准备消息;
消息队列中间件根据所述准备消息向所述事务发起方返回所述事务的全局事务标识。
可选的,所述消息队列中间件获得所述事务的全局事务标识,包括:
消息队列中间件获取事务发起方发送的所述事务的全局事务标识。
需要说明的是,对于本申请第四实施例提供的电子设备的详细描述可以参考对本申请第一实施例的相关描述,这里不再赘述。
与本申请第一实施例提供的一种事务处理方法相对应的,本申请第五实施例还提供了一种存储设备,存储有事务处理方法的程序,该程序被处理器运行,执行下述步骤:
消息队列中间件获得所述事务的全局事务标识;
消息队列中间件接收所述事务发起方发送的针对所述全局事务标识的事务处理消息;
消息队列中间件根据所述事务处理消息进行事务处理,推进事务执行。
需要说明的是,对于本申请第五实施例提供的存储设备的详细描述可以参考对本申请第一实施例的相关描述,这里不再赘述。
与本申请第二实施例提供的一种事务处理方法相对应的,本申请第六实施例还提供了一种事务处理装置。
如图9所示,所述事务处理装置包括:
全局事务标识获得单元901,用于获得所述事务的全局事务标识;
事务处理消息发送单元902,用于向所述消息队列中间件发送针对所述全局事务标 识的事务处理消息。
可选的,所述装置还包括:
执行结果消息发送单元,用于向消息队列中间件发送所述事务的子事务的执行结果消息;所述执行结果消息,包括:子事务的执行结果、子事务标识及所述全局事务标识。
可选的,所述事务处理消息包括事务提交消息;
所述事务处理消息发送单元,具体用于:
当所述分布式事务的子事务全部执行成功时,向所述消息队列中间件发送针对所述全局事务标识的事务提交消息。
可选的,所述事务处理消息包括事务回滚消息;
所述事务处理消息发送单元,具体用于:
当所述事务的子事务中有至少一个子事务执行失败时,向所述消息队列中间件发送针对所述全局事务标识的事务回滚信息。
可选的,所述装置还包括:
回查请求消息接收单元,用于接收消息队列中间件发送的回查请求消息;所述回查请求中包括:已经执行成功的子事务的标识以及事务的全局事务标识;
处理消息发送单元,用于根据所述回查请求消息,向所述消息中间件发送事务提交消息或事务回滚消息。
可选的,所述装置还包括:
子事务服务调用单元,用于远程调用所述事务的子事务对应的服务。
可选的,所述装置还包括:
子事务执行结果接收单元,用于接收所述子事务对应的服务返回的子事务的执行结果。
可选的,所述全局事务标识获得单元,具体用于:
向消息队列中间件发送触发消息队列中间件生成所述事务的全局事务标识的准备消息;
接收所述消息队列中间件返回的所述事务的全局事务标识。
可选的,所述全局事务标识获得单元,具体用于:
事务发起方产生所述事务的全局事务标识;
所述装置还包括:全局事务标识发送单元,
用于将所述事务的全局事务标识发送给消息队列中间件。
需要说明的是,对于本申请第六实施例提供的事务处理装置的详细描述可以参考对本申请第二实施例的相关描述,这里不再赘述。
与本申请第二实施例提供的一种事务处理方法相对应的,本申请第七实施例还提供了一种电子设备。
如图10所示,所述电子设备包括:
处理器1001;以及
存储器1002,用于存储事务处理方法的程序,该设备通电并通过所述处理器运行该事务处理方法的程序后,执行下述步骤:
获得所述事务的全局事务标识;
向所述消息队列中间件发送针对所述全局事务标识的事务处理消息。
可选的,所述电子设备还用于执行下述步骤:向消息队列中间件发送所述事务的子事务的执行结果消息;所述执行结果消息,包括:子事务的执行结果、子事务标识及所述全局事务标识。
可选的,所述事务处理消息包括事务提交消息;
所述向所述消息队列中间件发送针对所述全局事务标识的事务处理消息,包括:
当所述分布式事务的子事务全部执行成功时,向所述消息队列中间件发送针对所述全局事务标识的事务提交消息。
可选的,所述事务处理消息包括事务回滚消息;
所述向所述消息队列中间件发送针对所述全局事务标识的事务处理消息,包括:
当所述事务的子事务中有至少一个子事务执行失败时,向所述消息队列中间件发送针对所述全局事务标识的事务回滚信息。
可选的,所述电子设备还用于执行下述步骤:
接收消息队列中间件发送的回查请求消息;所述回查请求中包括:已经执行成功的子事务的标识以及事务的全局事务标识;
根据所述回查请求消息,向所述消息中间件发送事务提交消息或事务回滚消息。
可选的,所述电子设备还用于执行下述步骤:
远程调用所述事务的子事务对应的服务。
可选的,所述电子设备还用于执行下述步骤:
接收所述子事务对应的服务返回的子事务的执行结果。
可选的,所述获得所述事务的全局事务标识,包括:
向消息队列中间件发送触发消息队列中间件生成所述事务的全局事务标识的准备消息;
接收所述消息队列中间件返回的所述事务的全局事务标识。
可选的,所述获得所述事务的全局事务标识,包括:
事务发起方产生所述事务的全局事务标识;
所述电子设备还用于执行下述步骤:
将所述事务的全局事务标识发送给消息队列中间件。
需要说明的是,对于本申请第七实施例提供的电子设备的详细描述可以参考对本申请第二实施例的相关描述,这里不再赘述。
与本申请第二实施例提供的一种事务处理方法相对应的,本申请第八实施例还提供了一种存储设备,存储有事务处理方法的程序,该程序被处理器运行,执行下述步骤:
获得所述事务的全局事务标识;
向所述消息队列中间件发送针对所述全局事务标识的事务处理消息。
需要说明的是,对于本申请第八实施例提供的存储设备的详细描述可以参考对本申请第二实施例的相关描述,这里不再赘述。
本申请虽然以较佳实施例公开如上,但其并不是用来限定本申请,任何本领域技术人员在不脱离本申请的精神和范围内,都可以做出可能的变动和修改,因此本申请的保护范围应当以本申请权利要求所界定的范围为准。
在一个典型的配置中,计算设备包括一个或多个处理器(CPU)、输入/输出接口、网络接口和内存。
内存可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM)。内存是计算机可读介质的示例。
计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器 (SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括非暂存电脑可读媒体(transitory media),如调制的数据信号和载波。
本领域技术人员应明白,本申请的实施例可提供为方法、系统或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。

Claims (27)

  1. 一种事务处理方法,其特征在于,包括:
    消息队列中间件获得所述事务的全局事务标识;
    消息队列中间件接收所述事务发起方发送的针对所述全局事务标识的事务处理消息;
    消息队列中间件根据所述事务处理消息进行事务处理,推进事务执行。
  2. 根据权利要求1所述的方法,其特征在于,所述事务处理消息,包括事务提交消息;
    所述消息队列中间件根据所述事务处理消息进行事务处理,包括:
    消息队列中间件根据所述事务提交消息进行事务提交处理。
  3. 根据权利要求1所述的方法,其特征在于,所述消息队列中间件根据所述事务提交消息进行事务提交处理,包括:
    消息队列中间件根据所述事务提交消息,标记所述全局事务标识对应的事务执行成功;
    消息队列中间件删除所述全局事务标识对应的事务记录。
  4. 根据权利要求1所述的方法,其特征在于,所述事务处理消息,包括事务回滚消息;
    所述消息队列中间件根据所述事务处理消息进行事务处理,包括:
    消息队列中间件根据所述事务回滚消息进行事务回滚处理。
  5. 根据权利要求4所述的方法,其特征在于,所述消息队列中间件根据所述事务回滚消息进行事务回滚处理,包括:
    消息队列中间件根据所述事务回滚消息,查找所述事务的已经成功执行的子事务;
    消息队列中间件向所述已经成功执行的子事务对应的服务发送回滚消息。
  6. 根据权利要求1所述的方法,其特征在于,还包括:
    消息队列中间件接收所述事务发起方发送的子事务的执行结果消息;所述执行结果消息,包括:子事务的执行结果、子事务标识及所述全局事务标识;
    将所述子事务的执行结果消息存储到所述全局事务标识的对应的事务记录中。
  7. 根据权利要求1所述的方法,其特征在于,还包括:
    消息队列中间件扫描在预设时间内未提交或未回滚的超时事务;
    消息队列中间件向所述超时事务对应的事务发起方发送回查请求消息。
  8. 根据权利要求7所述的方法,其特征在于,所述回查请求中包括:已经执行成功的子事务的标识以及对应的事务的全局事务标识。
  9. 根据权利要求7所述的方法,其特征在于,还包括:
    消息队列中间件接收所述超时事务对应的事务发起方发送的事务回滚消息或者事务提交消息。
  10. 根据权利要求1所述的方法,其特征在于,还包括:
    消息队列中间件扫描在预设时间内未提交或未回滚的超时事务;
    消息队列中间件向所述超时事务对应的执行成功的子事务的服务发送事务回滚消息。
  11. 根据权利要求1所述的方法,其特征在于,所述消息队列中间件获得所述事务的全局事务标识,包括:
    消息队列中间件获取事务的事务发起方发送的准备消息;
    消息队列中间件根据所述准备消息向所述事务发起方返回所述事务的全局事务标识。
  12. 根据权利要求1所述的方法,其特征在于,所述消息队列中间件获得所述事务的全局事务标识,包括:
    消息队列中间件获取事务发起方发送的所述事务的全局事务标识。
  13. 一种事务处理方法,其特征在于,包括:
    获得所述事务的全局事务标识;
    向消息队列中间件发送针对所述全局事务标识的事务处理消息。
  14. 根据权利要求13所述的方法,其特征在于,还包括:向消息队列中间件发送所述事务的子事务的执行结果消息;所述执行结果消息,包括:子事务的执行结果、子事务标识及所述全局事务标识。
  15. 根据权利要求13所述的方法,其特征在于,所述事务处理消息包括事务提交消息;
    所述向消息队列中间件发送针对所述全局事务标识的事务处理消息,包括:
    当分布式事务的子事务全部执行成功时,向所述消息队列中间件发送针对所述全局事务标识的事务提交消息。
  16. 根据权利要求13所述的方法,其特征在于,所述事务处理消息包括事务回滚消息;
    向消息队列中间件发送针对所述全局事务标识的事务处理消息,包括:
    当所述事务的子事务中有至少一个子事务执行失败时,向所述消息队列中间件发送针对所述全局事务标识的事务回滚信息。
  17. 根据权利要求13所述的方法,其特征在于,还包括:
    接收消息队列中间件发送的回查请求消息;所述回查请求中包括:已经执行成功的子事务的标识以及事务的全局事务标识;
    根据所述回查请求消息,向所述消息中间件发送事务提交消息或事务回滚消息。
  18. 根据权利要求13所述的方法,其特征在于,还包括:
    远程调用所述事务的子事务对应的服务。
  19. 根据权利要求18所述的方法,其特征在于,还包括:
    接收所述子事务对应的服务返回的子事务的执行结果。
  20. 根据权利要求13所述的方法,其特征在于,所述获得所述事务的全局事务标识,包括:
    向消息队列中间件发送触发消息队列中间件生成所述事务的全局事务标识的准备消息;
    接收所述消息队列中间件返回的所述事务的全局事务标识。
  21. 根据权利要求13所述的方法,其特征在于,所述获得所述事务的全局事务标识,包括:
    事务发起方产生所述事务的全局事务标识;
    所述方法还包括:
    将所述事务的全局事务标识发送给消息队列中间件。
  22. 一种事务处理装置,其特征在于,包括:
    全局事务标识获得单元,用于消息队列中间件获得所述事务的全局事务标识;
    事务处理消息接收单元,用于消息队列中间件接收所述事务发起方发送的针对所述全局事务标识的事务处理消息;
    事务处理单元,用于消息队列中间件根据所述事务处理消息进行事务处理,推进事务执行。
  23. 一种电子设备,其特征在于,包括:
    处理器;以及
    存储器,用于存储事务处理方法的程序,该设备通电并通过所述处理器运行该事务 处理方法的程序后,执行下述步骤:
    消息队列中间件获得所述事务的全局事务标识;
    消息队列中间件接收所述事务发起方发送的针对所述全局事务标识的事务处理消息;
    消息队列中间件根据所述事务处理消息进行事务处理,推进事务执行。
  24. 一种存储设备,其特征在于,
    存储有事务处理方法的程序,该程序被处理器运行,执行下述步骤:
    消息队列中间件获得所述事务的全局事务标识;
    消息队列中间件接收所述事务发起方发送的针对所述全局事务标识的事务处理消息;
    消息队列中间件根据所述事务处理消息进行事务处理,推进事务执行。
  25. 一种事务处理装置,其特征在于,包括:
    全局事务标识获得单元,用于获得所述事务的全局事务标识;
    事务处理消息发送单元,用于向所述消息队列中间件发送针对所述全局事务标识的事务处理消息。
  26. 一种电子设备,其特征在于,包括:
    处理器;以及
    存储器,用于存储事务处理方法的程序,该设备通电并通过所述处理器运行该事务处理方法的程序后,执行下述步骤:
    获得所述事务的全局事务标识;
    向消息队列中间件发送针对所述全局事务标识的事务处理消息。
  27. 一种存储设备,其特征在于,
    存储有事务处理方法的程序,该程序被处理器运行,执行下述步骤:
    获得所述事务的全局事务标识;
    向消息队列中间件发送针对所述全局事务标识的事务处理消息。
PCT/CN2019/118680 2018-11-27 2019-11-15 事务处理方法、装置和设备 Ceased WO2020108325A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201811426739.3A CN111225012A (zh) 2018-11-27 2018-11-27 事务处理方法、装置和设备
CN201811426739.3 2018-11-27

Publications (1)

Publication Number Publication Date
WO2020108325A1 true WO2020108325A1 (zh) 2020-06-04

Family

ID=70827999

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/118680 Ceased WO2020108325A1 (zh) 2018-11-27 2019-11-15 事务处理方法、装置和设备

Country Status (2)

Country Link
CN (1) CN111225012A (zh)
WO (1) WO2020108325A1 (zh)

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112925614A (zh) * 2021-03-04 2021-06-08 杭州网易云音乐科技有限公司 一种分布式事务处理方法、装置、介质和设备
CN113760566A (zh) * 2020-11-10 2021-12-07 北京沃东天骏信息技术有限公司 一种分布式事务处理的方法、装置、系统和存储介质
CN114168358A (zh) * 2021-10-22 2022-03-11 济南浪潮数据技术有限公司 消息处理方法和装置、分布式事务处理系统及计算机设备
CN114281603A (zh) * 2021-12-29 2022-04-05 中国邮政储蓄银行股份有限公司 一种事务对应的消息的发送方法及装置
CN114356596A (zh) * 2021-12-15 2022-04-15 苏州臻璇数据信息技术有限公司 分布式系统的消息处理方法和装置
CN114466071A (zh) * 2022-04-12 2022-05-10 北京宝兰德软件股份有限公司 一种基于MQ PaaS的事务消息处理方法及装置
CN114579259A (zh) * 2020-11-30 2022-06-03 腾讯科技(深圳)有限公司 子逻辑任务的处理方法、装置、设备及介质
CN114816679A (zh) * 2022-01-25 2022-07-29 冠通新创科技(上海)有限公司 一种基于mq实现的token机制分布式事务最终一致性中间件

Families Citing this family (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113872781B (zh) * 2020-06-30 2024-12-06 阿里巴巴集团控股有限公司 事务处理方法、装置、设备和存储介质
CN112346827B (zh) * 2020-11-12 2023-05-02 食亨(上海)科技服务有限公司 多事务系统的数据一致性方法及装置
CN112667418B (zh) * 2020-12-31 2023-07-18 重庆富民银行股份有限公司 基于消息队列高可用性的数据同步方法
CN113568716B (zh) * 2021-07-29 2025-06-17 上海浦东发展银行股份有限公司 一种事务处理方法、装置、电子设备及存储介质
CN113626157B (zh) * 2021-08-13 2024-03-26 中国工商银行股份有限公司 一种交易事务控制方法、装置和系统
CN114327799B (zh) * 2021-12-23 2022-08-05 杭州博盾习言科技有限公司 分布式事务处理方法及装置、电子设备、存储介质
CN115269161B (zh) * 2022-09-30 2022-12-20 浙江省公众信息产业有限公司无线运营分公司 一种异常流程逆向回滚方法和系统
CN115964441A (zh) * 2022-12-29 2023-04-14 金篆信科有限责任公司 一种数据库多写一致性的系统
CN116866343A (zh) * 2023-07-06 2023-10-10 中国移动通信集团江苏有限公司 分布式事务处理方法、装置、设备及计算机可读存储介质
CN117851089B (zh) * 2023-12-14 2025-11-04 天翼云科技有限公司 一种事务消息跨集群同步方法及系统

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007011896A (ja) * 2005-07-01 2007-01-18 Nippon Telegr & Teleph Corp <Ntt> 分散トランザクションシステム
US20120030184A1 (en) * 2010-07-27 2012-02-02 Sap Ag Distributed database system utilizing an extended two-phase-commit process
US20120246651A1 (en) * 2011-03-25 2012-09-27 Oracle International Corporation System and method for supporting batch job management in a distributed transaction system
CN107045454A (zh) * 2016-02-06 2017-08-15 华为技术有限公司 跨进程分布式事务控制方法及相关系统
CN108845867A (zh) * 2018-07-16 2018-11-20 郑州云海信息技术有限公司 一种分布式事务管理方法、装置、系统及存储介质

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102571850B (zh) * 2010-12-24 2014-08-06 中国移动通信集团山东有限公司 事务提交系统、方法及设备
CN102831156B (zh) * 2012-06-29 2014-12-31 浙江大学 一种云计算平台上的分布式事务处理方法
GB2516852A (en) * 2013-08-01 2015-02-11 Ibm Consuming ordered streams of messages in a message oriented middleware
CN105447000A (zh) * 2014-07-31 2016-03-30 阿里巴巴集团控股有限公司 一种事务消息的传输方法和设备
CN106156119A (zh) * 2015-04-07 2016-11-23 阿里巴巴集团控股有限公司 一种分布式事务通信方法、系统及装置
CN106155775B (zh) * 2015-04-28 2020-02-21 菜鸟智能物流控股有限公司 消息处理方法、设备及系统
CN105242975A (zh) * 2015-08-27 2016-01-13 浪潮软件股份有限公司 一种消息传输的方法和消息中间件
CN108009027B (zh) * 2017-11-23 2019-09-20 北京百度网讯科技有限公司 队列消息一致性的实现方法、装置、设备及存储介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007011896A (ja) * 2005-07-01 2007-01-18 Nippon Telegr & Teleph Corp <Ntt> 分散トランザクションシステム
US20120030184A1 (en) * 2010-07-27 2012-02-02 Sap Ag Distributed database system utilizing an extended two-phase-commit process
US20120246651A1 (en) * 2011-03-25 2012-09-27 Oracle International Corporation System and method for supporting batch job management in a distributed transaction system
CN107045454A (zh) * 2016-02-06 2017-08-15 华为技术有限公司 跨进程分布式事务控制方法及相关系统
CN108845867A (zh) * 2018-07-16 2018-11-20 郑州云海信息技术有限公司 一种分布式事务管理方法、装置、系统及存储介质

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113760566A (zh) * 2020-11-10 2021-12-07 北京沃东天骏信息技术有限公司 一种分布式事务处理的方法、装置、系统和存储介质
CN114579259A (zh) * 2020-11-30 2022-06-03 腾讯科技(深圳)有限公司 子逻辑任务的处理方法、装置、设备及介质
CN112925614A (zh) * 2021-03-04 2021-06-08 杭州网易云音乐科技有限公司 一种分布式事务处理方法、装置、介质和设备
CN114168358A (zh) * 2021-10-22 2022-03-11 济南浪潮数据技术有限公司 消息处理方法和装置、分布式事务处理系统及计算机设备
CN114356596A (zh) * 2021-12-15 2022-04-15 苏州臻璇数据信息技术有限公司 分布式系统的消息处理方法和装置
CN114281603A (zh) * 2021-12-29 2022-04-05 中国邮政储蓄银行股份有限公司 一种事务对应的消息的发送方法及装置
CN114816679A (zh) * 2022-01-25 2022-07-29 冠通新创科技(上海)有限公司 一种基于mq实现的token机制分布式事务最终一致性中间件
CN114466071A (zh) * 2022-04-12 2022-05-10 北京宝兰德软件股份有限公司 一种基于MQ PaaS的事务消息处理方法及装置
CN114466071B (zh) * 2022-04-12 2022-07-29 北京宝兰德软件股份有限公司 一种基于MQ PaaS的事务消息处理方法及装置

Also Published As

Publication number Publication date
CN111225012A (zh) 2020-06-02

Similar Documents

Publication Publication Date Title
WO2020108325A1 (zh) 事务处理方法、装置和设备
CN112988883B (zh) 数据库的数据同步方法、装置以及存储介质
CN111290866B (zh) 业务处理方法及装置
CN110888893A (zh) 一种基于微服务电商系统的订单处理方法
CN111277639B (zh) 一种保持数据一致性的方法和装置
CN111784329B (zh) 业务数据的处理方法和装置、存储介质、电子装置
CN110019514B (zh) 数据同步方法、装置以及电子设备
CN111813791A (zh) 一种分布式补偿事务的方法及设备
CN112822091B (zh) 一种消息处理方法和装置
CN106899648A (zh) 一种数据处理方法和设备
US11681683B2 (en) Transaction compensation for single phase resources
US11080146B2 (en) System and method for storage unavailability tolerant backup
CN106155775B (zh) 消息处理方法、设备及系统
CN107766080A (zh) 事务消息处理方法、装置、设备及系统
JP2017524190A (ja) データベース障害時のデータ記憶
CN107016016A (zh) 一种数据处理的方法及装置
CN110796545A (zh) 一种区块链交易的批处理方法、设备和存储介质
US9069632B2 (en) Message processing
CN111258742A (zh) 一种数据同步的方法、系统、计算设备及存储介质
CN115455121A (zh) 一种实时可靠的数据同步传输方法、设备及介质
US20120158813A1 (en) Service abstraction layer for accessing a plurality of services
CN107276970A (zh) 一种解绑、绑定方法和装置
CN112187916B (zh) 一种跨系统的数据同步方法与装置
CN108228581A (zh) Zookeeper兼容通信方法、服务器及系统
CN116303760A (zh) 银行核心系统的数据同步方法、装置和电子设备

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19889622

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19889622

Country of ref document: EP

Kind code of ref document: A1