Transaction processing method, device, equipment and storage medium
By combining SAGA and TCC distributed transaction modes in the distributed system of the core banking system, transaction processing and fund transfer preparation processing are solved, and the problems of transaction consistency and fund security in the SAGA model are achieved. Higher fund security and transaction processing consistency.
Patent Information
- Application Number
- CN202210087003.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-25
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2042-01-25
AI Technical Summary
During the process of moving the core banking system from the host system to the distributed system, the SAGA model is difficult to ensure transaction consistency and fund security.
The SAGA distributed transaction model is used to process the distributed transactions, and the capital flow information is sent to the fund processing center at the fund transfer node, and the fund transfer preparation processing is carried out based on the TCC distributed transaction model. If all processing nodes pass, a confirmation instruction will be sent to the Fund Processing Center to complete the preparation process for the funds transfer.
By extracting funds processing from the transaction processing logic and processing fund transfer nodes according to the TCC model, transaction processing and fund security improvement in distributed systems are achieved, avoiding the situation where funds cannot be returned.
Smart Images

Figure CN114493873B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of data processing technology, and in particular to a transaction processing method, apparatus, device and storage medium. Background Art
[0002] In the past, the core banking systems of my country's large banks were mostly based on host technology and built with a centralized architecture. However, with the continuous increase in business transactions, the core banking system has changed some applications from centralized deployment to distributed deployment, and moved transactions to the core banking system host system, thereby reducing unilateral dependence on the host, achieving independent control, and reducing security risks and costs.
[0003] In the process of moving core bank host system transactions to distributed systems, the SAGA (Smart Alliance Grid Architecture) model, which is highly compatible with the transaction processing logic of the bank host system, is usually used to process distributed transactions in a distributed system. However, the SAGA model is difficult to ensure transaction consistency and fund security in a distributed system. Summary of the invention
[0004] The embodiments of the present application provide a transaction processing method, apparatus, device and storage medium to improve the security of funds during transaction processing.
[0005] In a first aspect, an embodiment of the present application provides a transaction processing method, the method comprising:
[0006] According to the SAGA distributed transaction mode, transaction processing is performed on any transaction in the transaction execution sequence corresponding to the distributed transaction; wherein the transaction processing includes at least one processing node;
[0007] If the processing node of the transaction is a fund transfer node, the fund flow information of the transaction is obtained, and the fund flow information is sent to the fund processing center, so that the fund processing center can prepare for fund transfer of the transaction based on the fund flow information and the TCC distributed transaction mode;
[0008] Determine whether any processing node of the transaction has been executed successfully, and if so, determine whether the transaction is a target transaction in a preset arrangement order in the transaction execution sequence;
[0009] If so, a confirmation instruction for fund transfer is sent to the fund processing center, so that the fund processing center can confirm the preparation processing of fund transfer for any transaction in the transaction execution sequence.
[0010] In a second aspect, an embodiment of the present application further provides a transaction processing device, the device comprising:
[0011] A transaction processing module, used for performing transaction processing on any transaction in the transaction execution sequence corresponding to the distributed transaction according to the SAGA distributed transaction mode; wherein the transaction processing includes at least one processing node;
[0012] A fund flow information sending module, for obtaining the fund flow information of the transaction if the processing node of the transaction is a fund transfer node, and sending the fund flow information to a fund processing center, so that the fund processing center can prepare for fund transfer of the transaction based on the fund flow information and the TCC distributed transaction mode;
[0013] A target transaction judgment module is used to judge whether any processing node of the transaction has been executed successfully, and if so, to judge whether the transaction is a target transaction in a preset arrangement order in the transaction execution sequence;
[0014] The confirmation instruction sending module is used to send a confirmation instruction of fund transfer to the fund processing center if the transaction is a target transaction in a preset arrangement order in the transaction execution sequence, so that the fund processing center can confirm the preparation processing of fund transfer for any transaction in the transaction execution sequence.
[0015] In a third aspect, an embodiment of the present application further provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the transaction processing method as described in any one of the embodiments of the present application is implemented.
[0016] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored, wherein when the program is executed by a processor, the transaction processing method as described in any one of the embodiments of the present application is implemented.
[0017] The embodiment of the present application performs transaction processing on the transaction corresponding to the distributed transaction according to the SAGA distributed transaction mode; if the processing node of the transaction is a fund transfer node, the fund processing center performs preparation processing for the fund transfer of the transaction based on the TCC (Try-Confirm-Cancel) distributed transaction mode according to the fund flow information; if any processing node including the fund processing node in any transaction of the distributed transaction passes, it can be determined that the distributed transaction processing execution has passed, and the fund processing center can confirm the preparation processing of the fund transfer of any transaction in the transaction execution sequence. The above scheme realizes transaction processing in the process of moving the host system down to the distributed system and improves the fund security in the transaction processing process by extracting the fund processing from the transaction processing logic, and processing the nodes involved in the fund processing in the transaction processing according to the TCC mode, and other non-fund transactions are processed according to the transaction implementation logic of the SAGA mode. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 It is a flowchart of a transaction processing method in Embodiment 1 of the present application;
[0019] Figure 2 It is a flowchart of a transaction processing method in Embodiment 2 of the present application;
[0020] Figure 3 It is a structural block diagram of a transaction processing device in Embodiment 3 of the present application;
[0021] Figure 4 It is a structural diagram of an electronic device in Embodiment 4 of the present application. DETAILED DESCRIPTION
[0022] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.
[0023] Embodiment 1
[0024] Figure 1 This is a flow chart of a transaction processing method provided in the first embodiment of the present application. This embodiment is applicable to the case where the host system is moved down to the distributed system for transaction processing. The method can be executed by a transaction processing device, which can be implemented in software and / or hardware, such as Figure 1 As shown, the method specifically comprises the following steps:
[0025] S110. According to the SAGA distributed transaction model, perform transaction processing on any transaction in the transaction execution sequence corresponding to the distributed transaction; wherein the transaction processing includes at least one processing node.
[0026] The SAGA distributed transaction mode (hereinafter referred to as the SAGA mode) is a distributed transaction implementation mode based on compensatory transactions. In the SAGA mode, a distributed transaction can include multiple transactions, each of which supports forward transactions and reverse compensatory transactions. When the distributed transaction of the SAGA mode is executed, the forward transactions of each transaction are executed in sequence. If the forward transactions of all transactions are executed successfully, the distributed transaction is completed and submitted. If the forward transaction of any transaction fails to execute, the distributed transaction will execute the reverse compensatory transaction corresponding to the previously completed forward transaction, that is, roll back the successful forward transaction, so that the distributed transaction returns to the initial state. The SAGA mode has a high degree of adaptability to the transaction processing logic of the host system, and the transaction processing of the distributed system can be realized by moving the host system down without making major improvements to the SAGA mode.
[0027] Usually, the transaction chain of a distributed transaction will be executed in a certain business execution order, that is, each transaction in a distributed transaction is processed in the transaction execution order. The transaction execution order corresponding to the distributed transaction can be the business execution order or the transaction execution order corresponding to the SAGA mode. For example, the execution order of the loan transaction corresponding to the distributed transaction can be to verify the legitimacy of the customer's account, verify the account password, the amount of the deductor and the amount of the transferor, etc. Any transaction can be any transaction A1, A2, ..., An in the SAGA mode. For example, a transaction can be a loan transaction.
[0028] Exemplarily, the distributed master control can perform transaction processing on any transaction in the transaction execution order corresponding to the distributed transaction according to the SAGA distributed transaction mode. Among them, the distributed master control can serve as a distributed system application gateway, which is a unified entrance to the distributed system, and is mainly responsible for providing access control, security control, public application inspection, and distributed transaction global transaction number allocation for application processing or transaction processing. The distributed transaction global transaction number is the distributed ID. Among them, the transaction processing process of each transaction can include at least one processing node. Different transactions can be processed by different server nodes in the distributed system, and the distributed master control initiates and calls each server node. For example, transaction processing may include fund processing or other business processing, wherein fund processing may be transfer processing and other processing involving fund transfer, and other business processing may be quota processing, credit review processing, or information registration processing.
[0029] In an optional embodiment, before performing transaction processing on any transaction in the transaction execution sequence corresponding to the distributed transaction according to the SAGA distributed transaction model, it also includes: determining a target verification program corresponding to any transaction from preset candidate verification programs; verifying the transaction according to the target verification program to determine whether the transaction passes the verification; if so, performing transaction processing on any transaction in the transaction execution sequence corresponding to the distributed transaction according to the SAGA distributed transaction model.
[0030] The candidate verification program can be pre-set by relevant technical personnel. Exemplarily, the verification programs corresponding to different transactions can be pre-stored in the server associated with the processing node corresponding to each transaction. The target verification program can be a verification program corresponding to any transaction in the candidate verification program deployed in the server associated with each processing node. Among them, the candidate verification program can include account password verification, card number existence verification, card number freezing verification, deposit legitimacy verification and transaction channel verification.
[0031] Exemplarily, a target verification program corresponding to any transaction is determined from preset candidate verification programs; the transaction is verified according to the target verification program to determine whether the transaction passes the verification; if so, any transaction in the transaction execution sequence corresponding to the distributed transaction is processed according to the SAGA distributed transaction mode; if not, a transaction verification failure reminder message can be sent to relevant personnel, and the transaction processing can be terminated. Among them, the transaction failure reminder message can be a reminder of the failure reason of the verification failure, for example, the transaction failure reminder message can be an account password verification failure or a card number does not exist, etc., and the relevant staff can set different transaction failure reminder messages according to different transactions.
[0032] This optional embodiment verifies any transaction according to a preset target verification procedure associated with any transaction before processing the transaction, determines whether the transaction passes the verification, and if so, executes subsequent transaction processing, thereby improving the security of the subsequent transaction processing process and avoiding economic losses caused by information verification errors or information omissions of the transaction parties.
[0033] S120. If the processing node of the transaction is a fund transfer node, the fund flow information of the transaction is obtained, and the fund flow information is sent to the fund processing center, so that the fund processing center can prepare for fund transfer of the transaction based on the fund flow information and the TCC distributed transaction model.
[0034] Among them, the fund transfer node is used for fund processing, that is, any fund processing in the transaction, such as loan or deposit. Fund flow information may include the initiation time, initiation amount and remaining amount. The fund processing center can be a server node for fund processing in a distributed system. For example, the fund processing center confirms and releases funds.
[0035] The TCC distributed transaction mode (hereinafter referred to as the TCC mode) is the abbreviation of the three operations of try or prepare operation (Try), confirm operation (Confirm) and cancel operation (Cancel). The TCC mode ensures the atomic submission of distributed transactions through atomicity, controls the concurrent access of distributed transactions through business isolation, and the transaction consistency of distributed transactions.
[0036] The business meanings of the three operations in the TCC mode are as follows: The Try phase is used to complete all business checks and reserve necessary business resources. Among them, the business can be a fund processing business; Confirm phase: the actual business logic is executed, the business is confirmed and submitted, no business checks are performed, and only the business resources reserved in the Try phase are used. By default, the Confirm phase will not go wrong. As long as the Try succeeds, the Confirm will succeed; Cancel phase: when an error occurs in the business execution and a rollback is required, the business is canceled and the reserved business resources are released.
[0037] For example, the distributed master control can send the acquired transaction fund flow information to the fund processing center. After acquiring the fund flow information, the fund processing center performs preparation processing on the transaction based on the TCC distributed transaction mode, that is, performs a Try operation on the transaction.
[0038] S130, determining whether any processing node of the transaction has been executed successfully, and if so, determining whether the transaction is a target transaction in a preset arrangement order in the transaction execution sequence.
[0039] Among them, any processing node may include a fund transfer node and other business processing nodes. For example, other business processing nodes may be processing nodes for quotas or information review processing nodes, etc. The preset arrangement order may be preset by relevant technical personnel, for example, the preset arrangement order may be the position of the last processing node in the transaction execution order. The target transaction may be the transaction corresponding to the last processing node in the transaction execution order.
[0040] Determine whether all the processing nodes of the transaction have been executed. If so, determine whether the transaction is the target transaction arranged at the last position in the transaction execution order.
[0041] S140: If yes, a confirmation instruction of fund transfer is sent to the fund processing center, so that the fund processing center can confirm the preparation process of fund transfer for any transaction in the transaction execution sequence.
[0042] Exemplarily, if the transaction is a target transaction in a preset arrangement order in the transaction execution sequence, for example, the transaction is the last transaction in the transaction execution sequence, then it can be determined that all transactions corresponding to the distributed transaction have been executed. A confirmation instruction for fund transfer can be sent to the fund processing center through the distributed master control. After receiving the confirmation instruction for fund transfer, the fund processing center performs a confirmation operation on the preparation processing of fund transfer of any transaction in the transaction execution sequence, that is, the fund processing center performs a confirmation operation on the fund transfer of any transaction that has been successfully tried according to the TCC mode.
[0043] In an optional embodiment, a distributed transaction corresponds to a unique distributed ID, and the fund flow information includes the distributed ID; the fund processing center includes the fund flow information of multiple distributed transactions; accordingly, a confirmation instruction for the fund transfer is sent to the fund processing center, so that the fund processing center can confirm the preparation processing of the fund transfer of any transaction in the transaction execution sequence, including: sending a confirmation instruction for the fund transfer corresponding to the distributed ID to the fund processing center, so that the fund processing center can determine the target fund flow information according to the distributed ID, and confirm the preparation processing of the fund transfer corresponding to the target fund flow information.
[0044] Among them, the distributed ID (Identity) can represent the unique identification of a distributed transaction in a distributed system. For example, the distributed ID can be generated by the snowflake algorithm. The ID generated by the snowflake algorithm is a 64-bit long number, which is an increasing number and can be used for sorting. The snowflake algorithm can basically maintain global uniqueness. The target fund flow information can be the fund flow information corresponding to each transaction under the distributed ID.
[0045] Exemplarily, the distributed master control can generate a distributed ID and transmit it to any transaction, that is, the distributed ID of each transaction in the transaction execution order of a distributed transaction is the same; in the process of fund processing for any transaction, when the fund flow information is sent to the fund processing center, the distributed ID of the transaction is included in the fund flow information. When the fund transfer of any transaction is fully prepared (that is, all tries are successful), the distributed master control can initiate a fund transfer confirmation instruction corresponding to each transaction under the distributed ID to the fund processing center through the distributed ID; when the fund processing center receives the fund transfer confirmation instruction, it determines the fund flow information under the distributed ID as the target fund flow information, and confirms the preparation processing of the fund transfer corresponding to the target fund flow information, that is, the fund transfer confirmation is performed for all the fund flows with successful tries under the distributed ID.
[0046] This optional embodiment determines the unique distributed ID corresponding to the distributed transaction and initiates a confirmation instruction of the fund transfer to the fund processing center according to the distributed ID, thereby avoiding the submission error of the fund transfer action when there is at least one distributed transaction. The uniqueness and accuracy of the confirmation fund transfer instruction can be guaranteed by setting the distributed ID.
[0047] The embodiment of the present application performs transaction processing on the transaction corresponding to the distributed transaction according to the SAGA distributed transaction mode; if the processing node of the transaction is a fund transfer node, the fund processing center performs preparation processing for the fund transfer on the transaction based on the TCC distributed transaction mode according to the fund flow information; if any of the processing nodes including the fund processing node in any transaction passes, it can be determined that the transaction processing execution corresponding to the distributed transaction passes, and the fund processing center can confirm the preparation processing of the fund transfer of any transaction in the transaction execution sequence. The above scheme realizes the transaction processing in the process of moving the host system down to the distributed system and improves the fund security in the transaction processing process by extracting the fund processing from the transaction processing logic, and processing the nodes involved in the fund processing in the transaction processing according to the TCC mode, and other non-fund transactions are processed according to the transaction implementation logic of the SAGA mode. By confirming the preparation processing of the fund transfer after the transaction processing of any transaction passes, the situation that the funds cannot be withdrawn during the fund transfer process is avoided. Transaction consistency in the transaction processing process is achieved.
[0048] Embodiment 2
[0049] Figure 2 A flowchart of a transaction processing method provided in Example 2 of the present application is provided. This embodiment is optimized and improved on the basis of the above-mentioned technical solutions.
[0050] Furthermore, after the step "According to the SAGA distributed transaction model, perform transaction processing on any transaction in the transaction execution order corresponding to the distributed transaction", add the step "If the transaction processing node is an information confirmation node, obtain the transaction's pending confirmation information and confirm the pending confirmation information." to improve the transaction processing process of any transaction.
[0051] After the step of "determining whether any processing node of the transaction has been executed successfully", add the step of "if any processing node of the transaction has not been executed successfully, determine whether the processing node that has not been executed successfully is a fund transfer node; if so, send a fund transfer cancellation instruction to the fund processing center for the fund processing center to cancel the preparation for the fund transfer." Correspondingly, after the step of "determining whether the processing node that has not been executed successfully is a fund transfer node", add the step of "if the processing node that has not been executed successfully is not a fund transfer node, determine the processing nodes that have been executed successfully in the transaction, and determine the transactions that have been executed successfully according to the transaction execution order; according to the preset reverse compensation transaction rules, perform transaction rollback on the processing nodes that have been executed successfully in the transaction and the transactions that have been executed successfully in the transaction execution order." to improve the processing method for non-fund transfer nodes.
[0052] After the step "determine whether the transaction is the target transaction of the preset arrangement order in the transaction execution order", add the step "if the transaction is not the target transaction of the preset arrangement order in the transaction execution order, determine the next transaction of the transaction according to the transaction execution order as the pending transaction, and execute the transaction processing according to the SAGA distributed transaction mode for the pending transactions in the transaction execution order corresponding to the distributed transaction." to improve the processing method for non-target transactions.
[0053] like Figure 2 As shown, the method comprises the following specific steps:
[0054] S210. According to the SAGA distributed transaction model, perform transaction processing on any transaction in the transaction execution sequence corresponding to the distributed transaction; wherein the transaction processing includes at least one processing node.
[0055] S220: If the transaction processing node is an information confirmation node, the pending confirmation information of the transaction is obtained, and the pending confirmation information is confirmed.
[0056] The information confirmation node may be other business nodes except the fund transfer node, and the number of information confirmation nodes may include at least one. For example, the information confirmation node may include a quota processing node and an information review processing node. The information to be confirmed corresponds to each information confirmation node. For example, if the information confirmation node is a quota processing node, the information to be confirmed may be the quota information to be confirmed.
[0057] S230. If the processing node of the transaction is a fund transfer node, the fund flow information of the transaction is obtained, and the fund flow information is sent to the fund processing center, so that the fund processing center can prepare for fund transfer of the transaction based on the fund flow information and the TCC distributed transaction model.
[0058] S240, determining whether any processing node of the transaction has been executed successfully; if so, executing S250A, if not, executing S250B.
[0059] S250A, determining whether the transaction is a target transaction in a preset arrangement order in the transaction execution order, if so, executing S260A, if not, executing S260B.
[0060] S250B, determine whether the processing node that has not been executed is a fund transfer node, if so, execute S270A, if not, execute S270B.
[0061] S260A. Send a confirmation instruction of fund transfer to the fund processing center, so that the fund processing center can confirm the preparation processing of fund transfer for any transaction in the transaction execution sequence.
[0062] S260B. According to the transaction execution order, determine the next transaction of the transaction as the pending transaction, and execute transaction processing according to the SAGA distributed transaction mode for the pending transaction in the transaction execution order corresponding to the distributed transaction.
[0063] S270A. Send a funds transfer cancellation instruction to the funds processing center for the funds processing center to prepare for canceling the funds transfer.
[0064] For example, the distributed master control may send a fund transfer cancellation instruction to the fund processing center, and the fund processing center cancels the prepared fund transfer according to the fund transfer cancellation instruction. That is, the fund processing center cancels all fund flows that have been successfully tried.
[0065] S270B, determining the processing nodes that have been successfully executed in the transaction, and determining the transactions that have been successfully executed according to the transaction execution order.
[0066] S280. According to the preset reverse compensation transaction rules, the transaction is rolled back for the processing nodes that have been executed successfully in the transaction and the transactions that have been executed successfully in the transaction execution sequence.
[0067] Among them, the reverse compensation transaction rules can be pre-set by relevant technical personnel. For example, the reverse compensation transaction rules can be the reverse transaction in the SAGA mode, that is, the reverse compensation transaction. The transaction is rolled back for the processing nodes that have been executed in the transaction and the transactions that have been executed in the transaction execution sequence. Exemplarily, for any transaction that fails to execute, the distributed transaction will go back to execute the reverse compensation transaction of any previously completed transaction, roll back the successful transaction, and return the distributed transaction to the initial state before the transaction processing.
[0068] The embodiment of the present application achieves the comprehensiveness of the transaction processing process of any transaction by further improving if the processing node of the transaction is an information confirmation node, if any processing node of the transaction is not executed, and if the transaction is not a target transaction in the preset arrangement order in the transaction execution order. By extracting the funds processing from the transaction processing logic, and processing the nodes involved in the funds processing in the transaction processing according to the TCC mode, and processing other non-fund transactions according to the transaction implementation logic of the SAGA mode, the transaction processing in the process of moving the host system to the distributed system is realized, and the security of funds in the transaction processing process is improved. The embodiment of the present application proposes to extract the funds processing that is affected by subsequent transactions and hinders the successful transaction rollback from the transaction transformation from the transaction processing logic and uniformly implement it while the rest of the transaction implementation logic remains unchanged, thereby providing a host-downward distributed transaction implementation that has a small amount of transformation from the host's positive and negative transaction implementation logic and can ensure the consistency of distributed system transactions.
[0069] In a specific implementation, the distributed master control generates a global transaction number X (distributed ID), and submits transactions A1, A2, ..., An with global transaction number X in turn according to the execution order of the SAGA mode. Execute the verification procedure for each transaction Ai. Transaction processing is performed on Ai, including fund processing of transaction Ai, generating fund processing flow of Ai, and other non-fund business processing. Among them, the fund processing method for Ai is: send fund flow information to the fund processing center, and the fund processing center submits the try action of the fund flow with global transaction number X one by one according to the TCC mode. If a transaction Ai fails to execute, based on the SAGA mode, according to the reverse compensation transaction of the successfully executed transaction Aj, the transaction Aj is rolled back, and the distributed master control notifies the fund processing center to roll back all the successfully tried fund flows corresponding to the global transaction number X. If all transactions A1, A2, ..., An of the entire transaction chain are executed, and all try actions of the fund flow with global transaction number X are successful, the distributed master control notifies the fund processing center to execute the confirm action of all fund processing flows under global transaction number X, and the entire transaction chain is submitted successfully.
[0070] In a scenario of nested transactions, if transaction P involves distributed transactions, including services 1, 2, and 3, and service 2 includes services 4 and 5, then distributed transactions are nested. Under the premise that fund processing is separated from transactions, transaction P calls services 1, 2, and 3 in SAGA mode, and service 2 calls services 4 and 5 in SAGA mode. Only after services 4 and 5 are all successful will the distributed master control service 2 be informed of success; if any of services 4 and 5 fail, all will be rolled back and the distributed master control service 2 will be informed of failure. If service 2 fails, the successfully executed service will be rolled back.
[0071] If service 2 does not include service 4 and service 5, and service 1, service 2, service 3, service 4 and service 5 are in parallel relationship, then the entire transaction chain becomes service 1, service 2, service 3, service 4 and service 5, which are still executed in sequence in SAGA mode. If a service fails to be submitted, a compensating transaction is submitted for the successful service and all are rolled back.
[0072] For fund processing, the entire fund processing flow of the transaction is executed in TCC mode. For a specific fund flow, if its try function also involves a distributed service sub-call, it can be seen from the fact that the try action of the fund flow can be rolled back that the distributed service sub-call involved in the try action can also be rolled back, otherwise it cannot be ensured that the entire try action will be rolled back. For a certain fund flow, its confirm function involves a distributed service sub-call. It can be seen from the fact that the confirm of the fund flow can be successful that the distributed service sub-call it calls can also be successful. The distributed service sub-call can be initiated by asynchronous message notification, and it will be successful as long as the message can be delivered.
[0073] In the scenario of combining transactions between the old and new systems during the migration of the host system, it is necessary to ensure the transaction consistency of the combination of transactions between the old and new systems. The host system can be considered as a typical SAGA mode, and the newly implemented distributed system can be considered as a system that meets the conditions of the TCC mode. The TCC mode and the SAGA mode can be combined to ensure transaction consistency and fund security.
[0074] In a specific example, if business M has been moved down and business N has not been moved down, business M can be a bond business and business N can be a personal current account business. The transaction is that user A transfers 10,000 yuan to user B through business M, and user B transfers 10,000 yuan to user A through business N. The specific steps are as follows:
[0075] a. Submit the business M transfer transaction, and user A's currency is transferred to user B's fund processing flow. Try the fund processing flow, and the available balance of user A's currency account is -10,000.
[0076] b. Execute the host transaction and transfer 10,000 RMB of user B's funds to user A's account.
[0077] c. If the host transaction is successful, confirm the fund processing flow of the business M transfer transaction.
[0078] d. If the host transaction fails, cancel the fund processing flow of the business M transfer transaction and restore the available balance of the currency account of user A deducted by the Try action.
[0079] Embodiment 3
[0080] Figure 3 This is a schematic diagram of the structure of a transaction processing device provided in Example 3 of the present application. The transaction processing device provided in the embodiment of the present application can be applied to the case where the host system is moved down to the distributed system for transaction processing. The device can be implemented in software and / or hardware. Figure 3 As shown, the device specifically includes: a transaction processing module 301, a fund flow information sending module 302, a target transaction judgment module 303 and a confirmation instruction sending module 304. Among them,
[0081] The first transaction processing module 301 is used to perform transaction processing on any transaction in the transaction execution sequence corresponding to the distributed transaction according to the SAGA distributed transaction mode; wherein the transaction processing includes at least one processing node;
[0082] A fund flow information sending module 302 is used to obtain the fund flow information of the transaction if the processing node of the transaction is a fund transfer node, and send the fund flow information to the fund processing center, so that the fund processing center can prepare for fund transfer of the transaction based on the fund flow information and the TCC distributed transaction mode;
[0083] The target transaction determination module 303 is used to determine whether any processing node of the transaction has been executed successfully, and if so, to determine whether the transaction is a target transaction in a preset arrangement order in the transaction execution sequence;
[0084] The confirmation instruction sending module 304 is used to send a confirmation instruction of fund transfer to the fund processing center if the transaction is a target transaction in a preset arrangement order in the transaction execution sequence, so that the fund processing center can confirm the preparation processing of fund transfer for any transaction in the transaction execution sequence.
[0085] The embodiment of the present application performs transaction processing on the transactions corresponding to the distributed transactions according to the SAGA distributed transaction model; if the processing node of the transaction is a fund transfer node, the fund processing center performs preparation processing for the fund transfer of the transaction based on the fund flow information and the TCC distributed transaction model; if any of the processing nodes including the fund processing node in any transaction passes, it can be determined that the transaction processing execution corresponding to the distributed transaction has passed, and the fund processing center can confirm the preparation processing for the fund transfer of any transaction in the transaction execution sequence. The above scheme realizes transaction processing in the process of moving the host system down to the distributed system and improves the fund security in the transaction processing process by extracting the fund processing from the transaction processing logic, and processing the nodes involved in the fund processing in the transaction processing according to the TCC model, and processing other non-fund transactions according to the transaction implementation logic of the SAGA model.
[0086] Optionally, the device further comprises:
[0087] The target verification program determination module is used to determine the target verification program corresponding to any transaction from the preset candidate verification programs before processing any transaction in the transaction execution sequence corresponding to the distributed transaction according to the SAGA distributed transaction mode;
[0088] A transaction verification module, used to verify the transaction according to the target verification program, and determine whether the transaction passes the verification;
[0089] The second transaction processing module is used to process any transaction in the transaction execution sequence corresponding to the distributed transaction according to the SAGA distributed transaction mode if the transaction passes the verification.
[0090] Optionally, the distributed transaction corresponds to a unique distributed ID, and the fund flow information includes the distributed ID; the fund processing center includes fund flow information of multiple distributed transactions;
[0091] Accordingly, the confirmation instruction sending module 304 includes:
[0092] A confirmation instruction sending unit is used to send a confirmation instruction of the fund transfer corresponding to the distributed ID to the fund processing center, so that the fund processing center can determine the target fund flow information according to the distributed ID and confirm the preparation processing of the fund transfer corresponding to the target fund flow information.
[0093] Optionally, the device further comprises:
[0094] The to-be-confirmed information confirmation module is used to obtain the to-be-confirmed information of the transaction and confirm the to-be-confirmed information after processing any transaction in the transaction execution sequence corresponding to the distributed transaction according to the SAGA distributed transaction mode, if the processing node of the transaction is an information confirmation node.
[0095] Optionally, the device further comprises:
[0096] A fund transfer node determination module, for determining whether any processing node of the transaction has been successfully executed, and if any processing node of the transaction has not been successfully executed, determining whether the processing node that has not been successfully executed is a fund transfer node;
[0097] The cancellation instruction sending module is used to send a fund transfer cancellation instruction to the fund processing center if the processing node that has not been executed is a fund transfer node, so that the fund processing center can cancel the preparation process of the fund transfer.
[0098] Optionally, the device further comprises:
[0099] An executed transaction determination module is used to determine whether the processing node that has not been executed is a fund transfer node, if the processing node that has not been executed is not a fund transfer node, determine the processing node that has been executed in the transaction, and determine the executed transaction according to the transaction execution order;
[0100] The transaction rollback module is used to roll back the transactions that have been executed in the processing nodes and the transactions that have been executed in the transaction execution sequence according to the preset reverse compensation transaction rules.
[0101] Optionally, the device further comprises:
[0102] The third transaction processing module is used to determine whether the transaction is a target transaction in a preset arrangement order in the transaction execution order. If the transaction is not a target transaction in a preset arrangement order in the transaction execution order, determine the next transaction of the transaction according to the transaction execution order as a pending transaction, and execute transaction processing on the pending transactions in the transaction execution order corresponding to the distributed transaction according to the SAGA distributed transaction mode.
[0103] The above-mentioned transaction processing device can execute the transaction processing method provided by any embodiment of the present application, and has the corresponding functional modules and beneficial effects for executing each transaction processing method.
[0104] Embodiment 4
[0105] Figure 4 It is a structural schematic diagram of an electronic device provided in Example 4 of the present application. Figure 4 A block diagram of an exemplary electronic device 400 suitable for implementing the embodiments of the present application is shown. Figure 4 The electronic device 400 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0106] like Figure 4 As shown, the electronic device 400 is in the form of a general computing device. The components of the electronic device 400 may include but are not limited to: one or more processors or processing units 401, a system memory 402, and a bus 403 connecting different system components (including the system memory 402 and the processing unit 401).
[0107] Bus 403 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus structures. For example, these architectures include but are not limited to Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus and Peripheral Component Interconnect (PCI) bus.
[0108] The electronic device 400 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the electronic device 400, including volatile and non-volatile media, removable and non-removable media.
[0109] System memory 402 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 404 and / or cache memory 405. Electronic device 400 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, storage system 406 may be used to read and write non-removable, non-volatile magnetic media ( Figure 4 not shown, usually called a "hard drive"). Although Figure 4 Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, a DVD-ROM, or other optical medium) may be provided. In these cases, each drive may be connected to bus 403 via one or more data medium interfaces. Memory 402 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of each embodiment of the present application.
[0110] A program / utility 408 having a set (at least one) of program modules 407 may be stored, for example, in memory 402, such program modules 407 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. Program modules 407 generally perform the functions and / or methods of the embodiments described herein.
[0111] The electronic device 400 may also communicate with one or more external devices 409 (e.g., keyboards, pointing devices, displays 410, etc.), may communicate with one or more devices that enable a user to interact with the electronic device 400, and / or may communicate with any device that enables the electronic device 400 to communicate with one or more other computing devices (e.g., a network card, a modem, etc.). Such communication may be performed via an input / output (I / O) interface 411. Furthermore, the electronic device 400 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 412. As shown, the network adapter 412 communicates with other modules of the electronic device 400 via the bus 403. It should be understood that although Figure 4 Not shown, other hardware and / or software modules may be used in conjunction with electronic device 400, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0112] The processing unit 401 executes various functional applications and data processing by running the programs stored in the system memory 402, such as implementing a transaction processing method provided in an embodiment of the present application.
[0113] Embodiment 5
[0114] Embodiment 5 of the present application also provides a storage medium containing computer executable instructions, on which a computer program is stored. When the program is executed by a processor, a transaction processing method as provided in the embodiment of the present application is implemented, including: according to the SAGA distributed transaction model, transaction processing is performed on any transaction in the transaction execution order corresponding to the distributed transaction; wherein the transaction processing includes at least one processing node; if the processing node of the transaction is a funds transfer node, the fund flow information of the transaction is obtained, and the fund flow information is sent to a funds processing center, so that the funds processing center can prepare for the funds transfer of the transaction based on the funds flow information and the TCC distributed transaction model; it is determined whether any processing node of the transaction has been executed, and if so, it is determined whether the transaction is a target transaction in a preset arrangement order in the transaction execution order; if so, a funds transfer confirmation instruction is sent to the funds processing center, so that the funds processing center can confirm the preparation for the funds transfer of any transaction in the transaction execution order.
[0115] The computer storage medium of the embodiment of the present application can adopt any combination of one or more computer-readable media. Computer-readable media can be computer-readable signal media or computer-readable storage media. Computer-readable storage media can be, for example, but not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or devices, or any combination of the above. More specific examples (non-exhaustive lists) of computer-readable storage media include: electrical connections with one or more wires, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the above. In this document, computer-readable storage media can be any tangible medium containing or storing programs, which can be used by instruction execution systems, devices or devices or used in combination with them.
[0116] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0117] The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0118] Computer program code for performing the operation of the present application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (e.g., using an Internet service provider to connect through the Internet).
[0119] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. A transaction processing method, characterized in that: include: According to the SAGA distributed transaction model, a transaction is processed for any transaction in the transaction execution sequence corresponding to the distributed transaction; wherein the transaction processing includes at least one processing node; the distributed transaction corresponds to a unique distributed ID; If the processing node of the transaction is a fund transfer node, the fund flow information of the transaction is obtained, and the fund flow information is sent to the fund processing center, so that the fund processing center can prepare for fund transfer of the transaction based on the fund flow information and the TCC distributed transaction mode; the fund flow information includes the distributed ID; Determine whether any processing node of the transaction has been executed successfully, and if so, determine whether the transaction is the target transaction arranged at the last position in the transaction execution sequence; the target transaction is the transaction corresponding to the last processing node in the transaction execution sequence; If so, a confirmation instruction for the fund transfer corresponding to the distributed ID is sent to the fund processing center, so that the fund processing center can determine the target fund flow information based on the distributed ID and confirm the preparation processing of the fund transfer corresponding to the target fund flow information; the fund processing center includes the fund flow information of multiple distributed transactions.
2. The method according to claim 1, characterized in that According to the SAGA distributed transaction model, before any transaction in the transaction execution sequence corresponding to the distributed transaction is processed, it also includes: Determine a target verification procedure corresponding to any transaction from preset candidate verification procedures; Verifying the transaction according to the target verification procedure to determine whether the transaction passes the verification; If so, according to the SAGA distributed transaction model, transaction processing is performed on any transaction in the transaction execution sequence corresponding to the distributed transaction.
3. The method according to claim 1, characterized in that After processing any transaction in the transaction execution sequence corresponding to the distributed transaction according to the SAGA distributed transaction model, it also includes: If the processing node of the transaction is an information confirmation node, the pending confirmation information of the transaction is obtained, and the pending confirmation information is confirmed.
4. The method according to claim 1, characterized in that: After determining whether any processing node of the transaction has been executed successfully, the process further includes: If any processing node of the transaction fails to execute, determining whether the processing node that fails to execute is a fund transfer node; If so, a funds transfer cancellation instruction is sent to the funds processing center for the funds processing center to cancel the preparation process for the funds transfer.
5. The method according to claim 4, characterized in that After determining whether the processing node that has not been executed is a fund transfer node, the method further includes: If the processing node that has not been executed is not a fund transfer node, then determining the processing node that has been executed in the transaction, and determining the transaction that has been executed according to the transaction execution order; According to the preset reverse compensation transaction rules, the transaction is rolled back for the processing nodes that have been executed successfully in the transaction and the transactions that have been executed successfully in the transaction execution sequence.
6. The method according to claim 1, characterized in that After determining whether the transaction is a target transaction in a preset arrangement order in the transaction execution order, the method further includes: If the transaction is not the target transaction in the preset arrangement order in the transaction execution order, the next transaction of the transaction is determined according to the transaction execution order as the pending transaction, and transaction processing is performed on the pending transactions in the transaction execution order corresponding to the distributed transaction according to the SAGA distributed transaction model.
7. A transaction processing device, characterized in that: include: A transaction processing module, used for performing transaction processing on any transaction in the transaction execution sequence corresponding to the distributed transaction according to the SAGA distributed transaction mode; wherein the transaction processing includes at least one processing node; and the distributed transaction corresponds to a unique distributed ID; A fund flow information sending module, for obtaining the fund flow information of the transaction if the processing node of the transaction is a fund transfer node, and sending the fund flow information to a fund processing center, so that the fund processing center can prepare for fund transfer of the transaction based on the fund flow information and the TCC distributed transaction mode; the fund flow information includes the distributed ID; The target transaction judgment module is used to judge whether any processing node of the transaction has been executed successfully. If so, it is used to judge whether the transaction is the target transaction arranged at the last position in the transaction execution sequence; the target transaction is the transaction corresponding to the last processing node in the transaction execution sequence; A confirmation instruction sending module is used to send a confirmation instruction of the fund transfer corresponding to the distributed ID to the fund processing center if the transaction is a target transaction in a preset arrangement order in the transaction execution order, so that the fund processing center can determine the target fund flow information according to the distributed ID and confirm the preparation processing of the fund transfer corresponding to the target fund flow information; the fund processing center includes the fund flow information of multiple distributed transactions.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the transaction processing method as described in any one of claims 1-6 is implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the transaction processing method as described in any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Distributed service transaction processing method and device, electronic equipment and medium
CN112288577A