Transaction processing method, device, electronic device and computer readable medium
By receiving the transaction processing request, obtaining the transaction status identification of the sub-transaction list and the last sub-transaction, determining the type of the positive mode, and processing each sub-transaction in the sub-transaction list according to the corrective mode type, solving the inconsistency problem caused by the downstream service not supporting corrective, and realizing the consistency of transaction accounts.
Patent Information
- Application Number
- CN202111552497.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-17
- Publication Date
- 2025-05-02
- Estimated Expiration
- 2041-12-17
AI Technical Summary
In the downstream service called, if there is a service that does not support correctiveness, consistency guarantees will result in some inconsistency.
By receiving the transaction processing request, obtain the sub-transaction list and the transaction status identification of the last sub-transaction, and determine the type of the positive pattern. If the corrective mode is an external dependency corrective mode, call the microservice to obtain the original transaction message, update the transaction status identifier, and correct each sub-transaction in the sub-transaction list according to the updated status.
It ensures consistency of transaction accounts and avoids inconsistency in some transaction accounts.
Smart Images

Figure CN114240660B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data analysis technology, and in particular to a transaction processing method, device, electronic device and computer-readable medium. Background Art
[0002] At present, the transaction consistency guarantee method based on the reversal mode depends on the support of downstream services for the reversal transaction. If there is a key step in a combined transaction, and this step cannot support reversal, such as account cancellation, but the overall business is also related to it. At this time, if this step times out due to network problems, all outbound call services are reversaled according to the general reversal process, and the outbound call service of this key step cannot support reversal, inconsistency will occur. If the reversal is not performed, if this key step that does not support reversal actually fails, there is also the possibility of inconsistency. Therefore, once there is a situation where the outbound call service does not support reversal, the existing consistency guarantee measures will become invalid and the consistency of the combined service cannot be guaranteed.
[0003] When a transaction times out when calling a downstream service during execution, the transaction will choose to use the reversal method to roll back all previously called services in reverse order. After the transaction identifies the inconsistency, the consistency guarantee mechanism is activated to perform reversal one by one in reverse order according to the transaction flow records. Among the downstream services called, if there is a service that does not support reversal, using this method to ensure consistency will result in some inconsistencies.
[0004] In the process of implementing this application, the inventors found that there are at least the following problems in the prior art:
[0005] Among the downstream services called, if there are services that do not support reversal themselves, ensuring consistency in this way will cause some inconsistencies. Summary of the invention
[0006] In view of this, the embodiments of the present application provide a transaction processing method, device, electronic device and computer-readable medium, which can solve the problem that if there is a service in the existing downstream service that does not support reversal, consistency assurance in this way will cause partial inconsistencies.
[0007] To achieve the above objective, according to one aspect of an embodiment of the present application, a transaction processing method is provided, including:
[0008] Receive a transaction processing request, obtain the corresponding sub-transaction list and the transaction status identifier corresponding to the last sub-transaction in the sub-transaction list;
[0009] In response to determining that the transaction corresponding to the transaction status indicator is unsuccessful, determining a reversal mode type corresponding to the last sub-transaction;
[0010] In response to determining that the reversal mode type is the external dependency reversal mode, calling a corresponding microservice to obtain a corresponding original transaction message;
[0011] The transaction status identifier is updated according to the original transaction message, so as to perform reversal processing on each sub-transaction in the sub-transaction list according to the updated transaction status identifier.
[0012] Optionally, after determining the reversal mode type corresponding to the last sub-transaction, the method further includes:
[0013] In response to determining that the reversal mode type is a regular reversal mode, obtaining a function code corresponding to the last sub-transaction;
[0014] Determine whether the last sub-transaction supports reversal based on the function code. If so, reverse reversal is performed on each sub-transaction in the sub-transaction list starting from the last sub-transaction. If not, reverse reversal is performed on other sub-transactions in the sub-transaction list, where other sub-transactions are sub-transactions in the sub-transaction list excluding the last sub-transaction.
[0015] Optionally, updating the transaction status identifier according to the original transaction message includes:
[0016] Determine the actual transaction status based on the original transaction message;
[0017] In response to determining that the actual transaction status is successful, updating the transaction status indicator to a success indicator;
[0018] In response to the transaction status being identified as failure, the transaction status is updated to a failure status.
[0019] Optionally, performing reversal processing on each sub-transaction in the sub-transaction list according to the updated transaction status identifier includes:
[0020] In response to the updated transaction status being identified as a success, no reversal operation is performed on each sub-transaction in the sub-transaction list, and a request processing completion identification is returned.
[0021] Optionally, performing reversal processing on each sub-transaction in the sub-transaction list according to the updated transaction status identifier includes:
[0022] In response to the updated transaction status being identified as a failure, a reverse reversal operation is performed on other sub-transactions in the sub-transaction list, and a reverse reversal operation result is returned.
[0023] Optionally, reverse reversal operations are performed on other sub-transactions in the sub-transaction list, including:
[0024] Obtain skip reversal configuration information, and then determine the corresponding transaction identifier;
[0025] Based on the transaction ID, perform reverse reversal operations on other sub-transactions in the sub-transaction list.
[0026] Optionally, based on the transaction identifier, a reverse reversal operation is performed on other sub-transactions in the sub-transaction list, including:
[0027] When performing a reverse reversal operation on other sub-transactions in the sub-transaction list, the transaction corresponding to the transaction identifier is skipped.
[0028] In addition, the present application also provides a transaction processing device, including:
[0029] A receiving unit is configured to receive a transaction processing request, obtain a corresponding sub-transaction list and a transaction status identifier corresponding to the last sub-transaction in the sub-transaction list;
[0030] a reversal mode type determination unit, configured to determine a reversal mode type corresponding to the last sub-transaction in response to determining that the transaction corresponding to the transaction status identifier is unsuccessful;
[0031] The transaction original message acquisition unit is configured to, in response to determining that the reversal mode type is the external dependency reversal mode, call the corresponding microservice to obtain the corresponding transaction original message;
[0032] The reversal unit is configured to update the transaction status identifier according to the original transaction message, so as to perform reversal processing on each sub-transaction in the sub-transaction list according to the updated transaction status identifier.
[0033] Optionally, the reversal mode type determination unit is further configured to:
[0034] In response to determining that the reversal mode type is a regular reversal mode, obtaining a function code corresponding to the last sub-transaction;
[0035] Determine whether the last sub-transaction supports reversal based on the function code. If so, reverse reversal is performed on each sub-transaction in the sub-transaction list starting from the last sub-transaction. If not, reverse reversal is performed on other sub-transactions in the sub-transaction list, where other sub-transactions are sub-transactions in the sub-transaction list excluding the last sub-transaction.
[0036] Optionally, the positive unit is further configured to:
[0037] Determine the actual transaction status based on the original transaction message;
[0038] In response to determining that the actual transaction status is successful, updating the transaction status indicator to a success indicator;
[0039] In response to the transaction status being identified as failure, the transaction status is updated to a failure status.
[0040] Optionally, the correction unit is further configured to:
[0041] In response to the updated transaction status being identified as a success, no reversal operation is performed on each sub-transaction in the sub-transaction list, and a request processing completion identification is returned.
[0042] Optionally, the correction unit is further configured to:
[0043] In response to the updated transaction status being identified as a failure, a reverse reversal operation is performed on other sub-transactions in the sub-transaction list, and a reverse reversal operation result is returned.
[0044] Optionally, the correction unit is further configured to:
[0045] Obtain skip reversal configuration information, and then determine the corresponding transaction identifier;
[0046] Based on the transaction ID, perform reverse reversal operations on other sub-transactions in the sub-transaction list.
[0047] Optionally, the correction unit is further configured to:
[0048] When performing a reverse reversal operation on other sub-transactions in the sub-transaction list, the transaction corresponding to the transaction identifier is skipped.
[0049] In addition, the present application also provides a transaction processing electronic device, including: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by one or more processors, the one or more processors implement the transaction processing method as described above.
[0050] In addition, the present application also provides a computer-readable medium on which a computer program is stored, and when the program is executed by a processor, the transaction processing method as described above is implemented.
[0051] To achieve the above objective, according to another aspect of the embodiments of the present application, a computer program product is provided.
[0052] A computer program product according to an embodiment of the present application includes a computer program, and when the program is executed by a processor, the transaction processing method provided by the embodiment of the present application is implemented.
[0053] One embodiment of the above invention has the following advantages or beneficial effects: the present application receives a transaction processing request, obtains the corresponding sub-transaction list and the transaction status identifier corresponding to the last sub-transaction in the sub-transaction list; in response to determining that the transaction corresponding to the transaction status identifier is unsuccessful, determines the reversal mode type corresponding to the last sub-transaction; in response to determining that the reversal mode type is an external dependency reversal mode, calls the corresponding microservice to obtain the corresponding transaction original message; updates the transaction status identifier according to the transaction original message, and performs reversal processing on each sub-transaction in the sub-transaction list according to the updated transaction status identifier. By determining the reversal mode type for the last sub-transaction in the sub-transaction list, an external dependency reversal mode is introduced, and when the reversal mode type is an external dependency reversal mode, the original transaction message is obtained to update the transaction status identifier, and then the reversal processing of each sub-transaction is performed according to the updated transaction status identifier, thereby ensuring the consistency of transaction accounts and avoiding the situation where some transaction accounts are inconsistent.
[0054] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] The accompanying drawings are used to better understand the present application and do not constitute an improper limitation on the present application.
[0056] Figure 1 is a schematic diagram of the main process of the transaction processing method according to the first embodiment of the present application;
[0057] Figure 2 is a schematic diagram of the main process of the transaction processing method according to the second embodiment of the present application;
[0058] Figure 3 is a schematic diagram of an application scenario of a transaction processing method according to a third embodiment of the present application;
[0059] Figure 4 is a schematic diagram of the main units of the transaction processing device according to an embodiment of the present application;
[0060] Figure 5 is an exemplary system architecture diagram to which the embodiments of the present application can be applied;
[0061] Figure 6 It is a structural diagram of a computer system of a terminal device or server suitable for implementing an embodiment of the present application. DETAILED DESCRIPTION
[0062] The following is a description of exemplary embodiments of the present application in conjunction with the accompanying drawings, including various details of the embodiments of the present application to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present application. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description. The acquisition, storage, use, and processing of data in the technical solution of the present application are in compliance with the relevant provisions of national laws and regulations.
[0063] Figure 1 is a schematic diagram of the main process of the transaction processing method according to the first embodiment of the present application, such as Figure 1 As shown, the transaction processing method includes:
[0064] Step S101, receiving a transaction processing request, obtaining a corresponding sub-transaction list and a transaction status identifier corresponding to the last sub-transaction in the sub-transaction list.
[0065] In this embodiment, the execution subject of the transaction processing method (for example, it can be a server) can receive the transaction processing request through a wired connection or a wireless connection. Obtain the corresponding sub-transaction list (for example, sub-transaction 1, sub-transaction 2, sub-transaction 3... arranged in sequence) and the transaction status identifier corresponding to the last sub-transaction in the sub-transaction list, for example, it can be 00, 01, 02 or other numbers or letters. Among them, 00 can represent success, 01 can represent failure, and 02 can represent timeout unknown. The embodiment of the present application does not limit the specific representation form and corresponding meaning of the transaction status identifier.
[0066] Step S102, in response to determining that the transaction corresponding to the transaction status identifier is unsuccessful, determining the reversal mode type corresponding to the last sub-transaction.
[0067] For example, if the transaction status is identified as 01 or 02, it may indicate that the corresponding transaction was unsuccessful, which may include transaction failure and unknown transaction timeout. Then, the execution entity may determine the type of reversal mode corresponding to the last sub-transaction, such as an external dependency reversal mode or a conventional reversal mode. Among them, the external dependency reversal mode can query the original message of the transaction to determine the actual status of the transaction when the transaction does not support reversal. The conventional reversal mode is to perform reversal when the transaction supports reversal, and terminate the reversal process when it does not support reversal.
[0068] Step S103, in response to determining that the reversal mode type is the external dependency reversal mode, calling the corresponding microservice to obtain the corresponding original transaction message.
[0069] The embodiment of the present application sets an external dependent reversal mode on the last sub-transaction in the transaction list, so that when the last sub-transaction does not support conventional reversal, the actual transaction status of the last sub-transaction can be determined by querying the original transaction message.
[0070] Step S104, updating the transaction status identifier according to the original transaction message, so as to perform reversal processing on each sub-transaction in the sub-transaction list according to the updated transaction status identifier.
[0071] By determining whether a transaction is successful or failed based on the actual transaction status of the last sub-transaction, if the last sub-transaction is successful, there is no need to roll back, and the problem of needing to initiate the transaction again is avoided, which improves availability and ensures the consistency of the overall combined service. If the last sub-transaction fails, the other transactions in the transaction list are reversed one by one.
[0072] This embodiment receives a transaction processing request, obtains the corresponding sub-transaction list and the transaction status identifier corresponding to the last sub-transaction in the sub-transaction list; in response to determining that the transaction corresponding to the transaction status identifier is unsuccessful, determines the reversal mode type corresponding to the last sub-transaction; in response to determining that the reversal mode type is an external dependency reversal mode, calls the corresponding microservice to obtain the corresponding transaction original message; updates the transaction status identifier according to the transaction original message, and performs reversal processing on each sub-transaction in the sub-transaction list according to the updated transaction status identifier. By determining the reversal mode type for the last sub-transaction in the sub-transaction list, an external dependency reversal mode is introduced, and when the reversal mode type is an external dependency reversal mode, the transaction original message is obtained to update the transaction status identifier, and then the reversal processing of each sub-transaction is performed according to the updated transaction status identifier, thereby ensuring the consistency of transaction accounts and avoiding the situation where some transaction accounts are inconsistent.
[0073] Figure 2 is a schematic diagram of the main flow of the transaction processing method according to the second embodiment of the present application, such as Figure 2 As shown, the transaction processing method includes:
[0074] Step S201, receiving a transaction processing request, obtaining a corresponding sub-transaction list and a transaction status identifier corresponding to the last sub-transaction in the sub-transaction list.
[0075] Step S202, in response to determining that the transaction corresponding to the transaction status identifier is unsuccessful, determining the reversal mode type corresponding to the last sub-transaction.
[0076] Step S203, in response to determining that the reversal mode type is the external dependency reversal mode, calling the corresponding microservice to obtain the corresponding original transaction message.
[0077] Step S204, updating the transaction status identifier according to the original transaction message, so as to perform reversal processing on each sub-transaction in the sub-transaction list according to the updated transaction status identifier.
[0078] The principles of steps S201 to S204 are similar to those of steps S101 to S104 and will not be described in detail herein.
[0079] Specifically, updating the transaction status identifier according to the original transaction message includes:
[0080] Determine the actual transaction status according to the original transaction message; in response to determining that the actual transaction status is successful, update the transaction status identifier to a success identifier, such as 00; in response to the transaction status identifier being a failure, update the transaction status identifier to a failure identifier, such as 01.
[0081] Specifically, each sub-transaction in the sub-transaction list is reversed according to the updated transaction status identifier, including:
[0082] In response to the updated transaction status being identified as a success identifier, such as 00, no reversal operation is performed on each sub-transaction in the sub-transaction list, and a request processing completion identifier, such as success, is returned.
[0083] Specifically, each sub-transaction in the sub-transaction list is reversed according to the updated transaction status identifier, including:
[0084] In response to the updated transaction status being identified as a failure, such as 01, a reverse reversal operation is performed on other sub-transactions in the sub-transaction list, and the reverse reversal operation result is returned. The reverse reversal operation result, for example, includes which transactions were successfully reversed and which transactions failed to be reversed. The returned transaction identifier may be the transaction identifier that failed to be reversed, which may be, for example, the order number of the transaction.
[0085] Specifically, the default reversal is reverse order, with the last transaction being the first.
[0086] For example, the execution subject can determine whether the last sub-transaction in the transaction list supports the external dependency reversal mode. If it supports the external dependency reversal mode, and the transaction status of the last sub-transaction is 02 (timeout unknown), the execution subject can call the distributed system to query the microservice corresponding to the transaction to find out what the actual transaction status is; if the actual transaction status of the transaction is 00 (success), then when the transaction timed out, the microservice had actually processed it successfully, but it did not respond in time, causing the timeout. Moreover, the transaction was the last sub-transaction, so the entire transaction link should be a successful transaction. The execution subject will change the overall transaction status to 00 (success), and the transaction does not need to be reversal. If the actual transaction status of the transaction is 01 (failure), the microservice failed to process the transaction, and the transaction has failed and does not need to be reversal. However, the transaction does not support reversal. In order to maintain the consistency of the overall transaction, the execution subject will reversal the other transactions in the transaction list one by one.
[0087] Specifically, the reverse order reversal operation is performed on other sub-transactions in the sub-transaction list, including:
[0088] Obtain skip reversal configuration information, and then determine the corresponding transaction identifier;
[0089] Based on the transaction ID, perform reverse reversal operations on other sub-transactions in the sub-transaction list.
[0090] Specifically, based on the transaction identifier, a reverse reversal operation is performed on other sub-transactions in the sub-transaction list, including:
[0091] When performing a reverse reversal operation on other sub-transactions in the sub-transaction list, the transaction corresponding to the transaction identifier is skipped.
[0092] Since the transaction currently being reversed may be a pre-check transaction (it will not be affected if it is not actually reversed), the execution subject can obtain the skip reversal configuration information, and then determine the transaction that needs to be skipped during the reversal, and skip the transaction during the reversal, so as to reduce the overall transaction link length, reduce transaction time, and achieve the purpose of business optimization. Because some transactions are only pre-check transactions in specific occasions, but are configured with an identification that needs to be reversed, the execution subject can skip the identification of the reversal and then skip the pre-check transaction to avoid the impact of too long transaction links.
[0093] Step S205, in response to determining that the reversal mode type is the regular reversal mode, obtaining a function code corresponding to the last sub-transaction.
[0094] Step S206, judging whether the last sub-transaction supports reversal according to the function code.
[0095] Step S207: If yes, reverse the sub-transactions in the sub-transaction list starting from the last sub-transaction.
[0096] Step S208: If not, reverse the order of other sub-transactions in the sub-transaction list, where the other sub-transactions are the sub-transactions in the sub-transaction list excluding the last sub-transaction.
[0097] The regular reversal mode is to perform regular reversal on the current transaction when the current transaction supports the regular reversal mode, and to end the regular reversal process of the current transaction when the current transaction does not support the regular reversal mode. When a transaction times out during execution and a call to a downstream service, the reversal method will be used to roll back all previously called services in reverse order. After the transaction identifies an inconsistency, the consistency guarantee mechanism is activated, and reversal is performed one by one in reverse order according to the transaction flow records. First, identify whether the service performs reversal. If it supports it, the reversal transaction is performed and the record status is updated; if it does not support it, it is skipped.
[0098] Figure 3 : is a schematic diagram of an application scenario of the transaction processing method according to the third embodiment of the present application. The transaction processing method of the embodiment of the present application can be applied to the scenario of consistency guarantee processing in the scenario where the key outbound call does not support reversal. Figure 3 As shown, when processing the reversal logic, first obtain the list of sub-transactions to be reversed (that is, obtain the list of outgoing transactions, a complete positive transaction may have multiple sub-transactions). If it cannot be obtained, the transaction processing process is terminated. Then obtain the reversal configuration information, and then determine whether reversal is required and the type of reversal mode based on the reversal configuration information. The default reversal is reverse reversal, and the last transaction is reversed at the front. The external dependency mode reversal configuration can be configured on the last transaction that does not support reversal.
[0099] The execution subject can determine whether the last sub-transaction in the transaction list supports the external dependency reversal mode. If it supports the external dependency reversal mode, and the transaction status of the last sub-transaction is 02 (timeout unknown), the execution subject can call the distributed system to query the microservice corresponding to the transaction to see what the actual transaction status is; if the actual transaction status of the transaction is 00 (success), then when the transaction timed out, the microservice had actually processed it successfully, but it did not respond in time, causing the timeout. Moreover, the transaction was the last sub-transaction, so the entire transaction link should be a successful transaction. The execution subject will change the overall transaction status to 00 (success), and the transaction does not need to be reversal. If the actual transaction status of the transaction is 01 (failure), the microservice failed to process the transaction, and the transaction has failed and does not need to be reversal. However, the transaction does not support reversal. In order to maintain the consistency of the overall transaction, the execution subject will reversal the other transactions in the transaction list one by one.
[0100] When the execution subject can determine that the last sub-transaction in the transaction list does not support the external dependency reversal mode, it will then determine whether it supports reversal. If so, it will initiate a reversal of the last sub-transaction. After the reversal of the last sub-transaction is completed, it is determined that the reversal of this transaction is completed, and the outgoing transaction list is continued to be obtained to continue to reverse the reversal of other sub-transactions in the transaction list. Otherwise, the last sub-transaction will not be reversed, it is determined that this reversal is completed, and the outgoing transaction list is continued to be obtained, and then the other sub-transactions in the transaction list are reversed.
[0101] The transaction to be reversed may be a pre-checked transaction (it will not have any impact if it is not actually reversed). The execution entity can obtain the skip reversal configuration information, and then determine the transaction that needs to be skipped during the reversal, and skip the transaction during the reversal to reduce the overall transaction link length, reduce transaction time, and achieve the purpose of business optimization.
[0102] The embodiments of the present application solve the problem of ensuring consistency of combined services when certain outbound calls do not support or do not need to be corrected under specific function codes; and solve the problem of ensuring consistency of the overall combined service when the key outbound call service in the combined transaction does not support reversal.
[0103] Figure 4 Schematic diagram of the main units of the transaction processing device according to the embodiment of the present application. Figure 4 As shown, the transaction processing device includes a receiving unit 401, a reversal mode type determination unit 402, a transaction original message acquisition unit 403 and a reversal unit 404.
[0104] The receiving unit 401 is configured to receive a transaction processing request, obtain a corresponding sub-transaction list and a transaction status identifier corresponding to the last sub-transaction in the sub-transaction list;
[0105] A reversal mode type determination unit 402 is configured to determine a reversal mode type corresponding to the last sub-transaction in response to determining that the transaction corresponding to the transaction status identifier is unsuccessful;
[0106] The transaction original message acquisition unit 403 is configured to, in response to determining that the reversal mode type is the external dependency reversal mode, call the corresponding microservice to obtain the corresponding transaction original message;
[0107] The reversal unit 404 is configured to update the transaction status identifier according to the original transaction message, so as to perform reversal processing on each sub-transaction in the sub-transaction list according to the updated transaction status identifier.
[0108] In some embodiments, the reversal mode type determination unit is further configured to:
[0109] In response to determining that the reversal mode type is a regular reversal mode, obtaining a function code corresponding to the last sub-transaction;
[0110] Determine whether the last sub-transaction supports reversal based on the function code. If so, reverse reversal is performed on each sub-transaction in the sub-transaction list starting from the last sub-transaction. If not, reverse reversal is performed on other sub-transactions in the sub-transaction list, where other sub-transactions are sub-transactions in the sub-transaction list excluding the last sub-transaction.
[0111] In some embodiments, the reversal unit 404 is further configured to: determine the actual transaction status based on the original transaction message; in response to determining that the actual transaction status is successful, update the transaction status identifier to a success identifier; in response to the transaction status identifier being a failure, update the transaction status identifier to a failure identifier.
[0112] In some embodiments, the reversal unit 404 is further configured to: in response to the updated transaction status being identified as a success identification, not perform a reversal operation on each sub-transaction in the sub-transaction list, and return a request processing completion identification.
[0113] In some embodiments, the reversal unit 404 is further configured to: in response to the updated transaction status being identified as a failure, perform a reverse reversal operation on other sub-transactions in the sub-transaction list, and return a reverse reversal operation result.
[0114] In some embodiments, the reversal unit 404 is further configured to: obtain skip reversal configuration information, and then determine the corresponding transaction identifier; and perform a reverse reversal operation on other sub-transactions in the sub-transaction list based on the transaction identifier.
[0115] In some embodiments, the reversal unit 404 is further configured to: when performing a reverse reversal operation on other sub-transactions in the sub-transaction list, skip the transaction corresponding to the transaction identifier.
[0116] It should be noted that the transaction processing method and the transaction processing device in the present application have a corresponding relationship in terms of specific implementation content, so the repeated content will not be explained again.
[0117] Figure 5 An exemplary system architecture 500 is shown to which the transaction processing method or transaction processing device according to the embodiment of the present application can be applied.
[0118] like Figure 5 As shown, system architecture 500 may include terminal devices 501, 502, 503, a network 504 and a server 505. Network 504 is used to provide a medium for communication links between terminal devices 501, 502, 503 and server 505. Network 504 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0119] Users can use terminal devices 501, 502, 503 to interact with server 505 through network 504 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 501, 502, 503, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).
[0120] The terminal devices 501, 502, 503 may be various electronic devices having a transaction processing screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.
[0121] Server 505 can be a server that provides various services, such as a background management server that provides support for transaction processing requests submitted by users using terminal devices 501, 502, and 503 (only as an example). The background management server can receive a transaction processing request, obtain the corresponding sub-transaction list and the transaction status identifier corresponding to the last sub-transaction in the sub-transaction list; in response to determining that the transaction corresponding to the transaction status identifier is unsuccessful, determine the reversal mode type corresponding to the last sub-transaction; in response to determining that the reversal mode type is an external dependency reversal mode, call the corresponding microservice to obtain the corresponding transaction original message; update the transaction status identifier according to the transaction original message, and perform reversal processing on each sub-transaction in the sub-transaction list according to the updated transaction status identifier. By determining the reversal mode type for the last sub-transaction in the sub-transaction list, an external dependency reversal mode is introduced, and when the reversal mode type is an external dependency reversal mode, the transaction original message is obtained to update the transaction status identifier, and then the reversal processing of each sub-transaction is performed according to the updated transaction status identifier, thereby ensuring the consistency of transaction accounts and avoiding the situation where some transaction accounts are inconsistent.
[0122] It should be noted that the transaction processing method provided in the embodiment of the present application is generally executed by the server 505, and accordingly, the transaction processing device is generally set in the server 505.
[0123] It should be understood that Figure 5 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0124] Reference below Figure 6 , which shows a schematic diagram of the structure of a computer system 600 of a terminal device suitable for implementing an embodiment of the present application. Figure 6 The terminal device 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.
[0125] like Figure 6As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage part 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the computer system 600 are also stored. The CPU 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0126] The following components are connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal processor (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage section 608 as needed.
[0127] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the central processing unit (CPU) 601, the above-mentioned functions defined in the system of the present application are executed.
[0128] It should be noted that the computer-readable medium shown in the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. Computer-readable storage media may include, for example, but are not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal 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 computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0129] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the above-mentioned module, program segment or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0130] The units involved in the embodiments described in the present application may be implemented by software or hardware. The units described may also be set in a processor, for example, it may be described as: a processor includes a receiving unit, a reversal mode type determination unit, a transaction original message acquisition unit and a reversal unit. The names of these units do not constitute limitations on the units themselves in some cases.
[0131] As another aspect, the present application also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently and not be assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device receives a transaction processing request, obtains the corresponding sub-transaction list and the transaction status identifier corresponding to the last sub-transaction in the sub-transaction list; in response to determining that the transaction corresponding to the transaction status identifier is unsuccessful, determines the reversal mode type corresponding to the last sub-transaction; in response to determining that the reversal mode type is an external dependency reversal mode, calls the corresponding microservice to obtain the corresponding transaction original message; updates the transaction status identifier according to the transaction original message, and performs reversal processing on each sub-transaction in the sub-transaction list according to the updated transaction status identifier.
[0132] The computer program product of the present application includes a computer program, and when the computer program is executed by a processor, the transaction processing method in the embodiment of the present application is implemented.
[0133] According to the technical solution of the embodiment of the present application, the reversal mode type is determined for the last sub-transaction in the sub-transaction list, and an external dependent reversal mode is introduced. When the reversal mode type is the external dependent reversal mode, the original transaction message is obtained to update the transaction status identifier, and then the reversal processing of each sub-transaction is performed according to the updated transaction status identifier, thereby ensuring the consistency of transaction accounts and avoiding the occurrence of inconsistencies in some transaction accounts.
[0134] The above specific implementations do not constitute a limitation on the protection scope of this application. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of this application should be included in the protection scope of this application.
Claims
1. A transaction processing method, characterized in that: include: Receive a transaction processing request, obtain a corresponding sub-transaction list and a transaction status identifier corresponding to the last sub-transaction in the sub-transaction list; In response to determining that the transaction corresponding to the transaction status identifier is unsuccessful, determining a reversal mode type corresponding to the last sub-transaction; In response to determining that the reversal mode type is an external dependency reversal mode, calling a corresponding microservice to obtain a corresponding original transaction message; Updating the transaction status identifier according to the original transaction message includes: determining an actual transaction status according to the original transaction message; in response to determining that the actual transaction status is successful, updating the transaction status identifier to a success identifier; in response to the transaction status identifier being a failure, updating the transaction status identifier to a failure identifier; Reversal processing is performed on each sub-transaction in the sub-transaction list according to the updated transaction status identifier, including: in response to the updated transaction status identifier being a success identifier, no reversal operation is performed on each sub-transaction in the sub-transaction list, and a request processing completion identifier is returned; in response to the updated transaction status identifier being a failure identifier, a reverse reversal operation is performed on other sub-transactions in the sub-transaction list, and the reverse reversal operation result is returned.
2. The method according to claim 1, characterized in that After determining the reversal mode type corresponding to the last sub-transaction, the method further includes: In response to determining that the reversal mode type is a conventional reversal mode, obtaining a function code corresponding to the last sub-transaction; Determine whether the last sub-transaction supports reversal according to the function code; if so, reverse reversal is performed on each sub-transaction in the sub-transaction list starting from the last sub-transaction; otherwise, reverse reversal is performed on other sub-transactions in the sub-transaction list, wherein the other sub-transactions are the sub-transactions in the sub-transaction list excluding the last sub-transaction.
3. The method according to claim 1, characterized in that The performing a reverse reversal operation on other sub-transactions in the sub-transaction list includes: Obtain skip reversal configuration information, and then determine the corresponding transaction identifier; Based on the transaction identifier, a reverse reversal operation is performed on other sub-transactions in the sub-transaction list.
4. The method according to claim 3, characterized in that The performing a reverse reversal operation on other sub-transactions in the sub-transaction list based on the transaction identifier includes: When performing a reverse reversal operation on other sub-transactions in the sub-transaction list, the transaction corresponding to the transaction identifier is skipped.
5. A transaction processing device, characterized in that: include: A receiving unit is configured to receive a transaction processing request, obtain a corresponding sub-transaction list and a transaction status identifier corresponding to the last sub-transaction in the sub-transaction list; a reversal mode type determination unit, configured to determine a reversal mode type corresponding to the last sub-transaction in response to determining that the transaction corresponding to the transaction status identifier is unsuccessful; The transaction original message acquisition unit is configured to, in response to determining that the reversal mode type is an external dependency reversal mode, call a corresponding microservice to obtain a corresponding transaction original message; The reversal unit is configured to update the transaction status identifier according to the original transaction message, including: determining the actual transaction status according to the original transaction message; in response to determining that the actual transaction status is successful, updating the transaction status identifier to a success identifier; in response to the transaction status identifier being a failure, updating the transaction status identifier to a failure identifier; performing reversal processing on each sub-transaction in the sub-transaction list according to the updated transaction status identifier, including: in response to the updated transaction status identifier being a success identifier, not performing a reversal operation on each sub-transaction in the sub-transaction list, and returning a request processing completion identifier; in response to the updated transaction status identifier being a failure identifier, performing a reverse reversal operation on other sub-transactions in the sub-transaction list, and returning a reverse reversal operation result.
6. The device according to claim 5, characterized in that The reversal mode type determination unit is further configured to: In response to determining that the reversal mode type is a conventional reversal mode, obtaining a function code corresponding to the last sub-transaction; Determine whether the last sub-transaction supports reversal according to the function code; if so, reverse reversal is performed on each sub-transaction in the sub-transaction list starting from the last sub-transaction; otherwise, reverse reversal is performed on other sub-transactions in the sub-transaction list, wherein the other sub-transactions are the sub-transactions in the sub-transaction list excluding the last sub-transaction.
7. The device according to claim 5, characterized in that The correction unit is further configured to: Obtain skip reversal configuration information, and then determine the corresponding transaction identifier; Based on the transaction identifier, a reverse reversal operation is performed on other sub-transactions in the sub-transaction list.
8. A transaction processing electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 4.
9. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
A reversal transaction processing method, device and equipment and a storage medium
CN113159960A
Method, device and equipment for controlling transaction consistency and computer readable medium
CN113486033A