Multi-mode business processing method, device and equipment

By adopting a multi-mode processing method in a distributed service system, the TCC mode sub-service is first pre-processed, and then the SAGA mode sub-service is processed, and the back-up process is performed when necessary, the inconsistency of business processing caused by different sub-service models is solved. Problem, improving reliability and stability.

CN113065967BActive Publication Date: 2024-12-10AGRICULTURAL BANK OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110538092.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-05-18
Publication Date
2024-12-10
Estimated Expiration
2041-05-18

AI Technical Summary

Technical Problem

The sub-business systems in existing distributed business systems have different models, and it is impossible to ensure that the results of distributed business processing are consistent, resulting in poor business processing reliability.

Method used

Using a multi-mode service processing method, the sub-services in TCC mode are pre-processed first. If the pre-processing is successful, the sub-services in SAGA mode are processed. If the execution result of the SAGA mode is successful, the execution process will be performed. If the failure occurs, the Back processing to ensure consistency of business processing.

Benefits of technology

It improves the reliability of distributed service processing, ensures the consistency of sub-service processing results, and enhances the stability of service processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113065967B_ABST
    Figure CN113065967B_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides a multi-mode business processing method, device and equipment, the method comprising: obtaining a business processing request, the business processing request is used to request processing of a first business, the first business includes at least one first sub-business and at least one second sub-business, and the modes of the first sub-business and the second sub-business are different; pre-processing each first sub-business respectively, the pre-processing is used to make the result of executing the first sub-business successful; if the pre-processing of at least one first sub-business is successful, then business processing is performed on at least one second sub-business to obtain a second execution result corresponding to at least one second sub-business; according to the second execution result, execution processing or rollback processing is performed on each first sub-business respectively to obtain a first execution result corresponding to each first sub-business, and the first execution result is the same as the second execution result. The reliability of business processing is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to computer technology, and in particular to a multi-mode business processing method, device and equipment. Background Art

[0002] A distributed business system can process distributed business. The distributed business system includes multiple sub-business systems. The distributed business includes multiple sub-businesses. One sub-business system is usually used to process one sub-business.

[0003] At present, the sub-business system can be a SAGA mode or a Try-Confirm-Cancel (TCC) mode for processing long-lived transactions. When processing distributed business, the distributed business processing system needs to ensure that the processing results of each sub-business in the distributed business are consistent, that is, either each sub-business is processed successfully, or each sub-business fails to be processed. In the related art, in order to ensure the consistency of the processing results of each sub-business in the distributed business, it is necessary to set the mode of each sub-business system in the distributed business system to the same mode. If the modes of each sub-business system in the business system are different, it is impossible to ensure that the processing results of each sub-business in the distributed business are consistent, which leads to poor reliability of business processing. Summary of the invention

[0004] The embodiments of the present application provide a multi-mode business processing method, device and equipment, which improve the reliability of business processing.

[0005] In a first aspect, an embodiment of the present application provides a multi-mode service processing method, including:

[0006] Obtaining a service processing request, where the service processing request is used to request processing of a first service, where the first service includes at least one first sub-service and at least one second sub-service, and the first sub-service and the second sub-service have different modes;

[0007] Preprocessing each first sub-service respectively, wherein the preprocessing is used to ensure that the result of executing the first sub-service is successful;

[0008] If the preprocessing of the at least one first sub-service is successful, performing service processing on the at least one second sub-service to obtain a second execution result corresponding to the at least one second sub-service;

[0009] According to the second execution result, each first sub-service is executed or rolled back to obtain a first execution result corresponding to each first sub-service, and the first execution result is the same as the second execution result.

[0010] In a possible implementation, according to the second execution result, each first sub-service is respectively executed or rolled back to obtain a first execution result corresponding to each first sub-service, including:

[0011] If the second execution result is successful execution, then each first sub-business is executed separately to obtain a first execution result corresponding to each first sub-business, and the first execution result corresponding to each first sub-business is successful execution;

[0012] If the second execution result is execution failure, each first sub-business is rolled back to obtain the first execution result corresponding to each first sub-business, and the first execution result corresponding to each first sub-business is execution failure.

[0013] In a possible implementation manner, for any first sub-service, performing rollback processing on the first sub-service to obtain a first execution result corresponding to the first sub-service includes:

[0014] The preprocessing of the first sub-service is rolled back to obtain a first execution result corresponding to the first sub-service, and the state of the first sub-service after the rollback is the same as the state of the first sub-service before the preprocessing.

[0015] In a possible implementation manner, if the second execution result is execution failure, the method further includes:

[0016] Determining a second sub-service that has been service-processed in the at least one second sub-service;

[0017] Perform reverse business processing on the second sub-business that has been processed.

[0018] In a possible implementation manner, performing a service on the at least one second sub-service to obtain a second execution result corresponding to the at least one second sub-service includes:

[0019] Determining an execution order of the at least one second sub-service;

[0020] The at least one second sub-business is processed in accordance with the execution order until each second sub-business is executed successfully, and the second execution result is determined to be a successful execution, or the second execution result is determined to be a failed execution when it is determined that any second sub-business in the at least one second sub-business fails to execute.

[0021] In a possible implementation manner, for any second sub-service, a state of the second sub-service after the reverse service processing is performed is the same as a state of the second sub-service before the service processing is performed.

[0022] In a possible implementation manner, for any first sub-service, preprocessing the first sub-service includes:

[0023] Obtaining a service parameter corresponding to the first sub-service in the service processing request;

[0024] Determining whether the service parameters meet the service requirements corresponding to the first sub-service;

[0025] When it is determined that the service parameter meets the service requirement corresponding to the first sub-service, service resources are allocated to the first sub-service, where the service resources are resources required for executing the first sub-service.

[0026] In a possible implementation manner, if preprocessing of any first sub-service of the at least one first sub-service fails, the method further includes:

[0027] Rollback processing is performed on the first sub-service that has undergone the preprocessing; wherein the state of the first sub-service after the rollback processing is the same as the state of the first sub-service before the preprocessing.

[0028] In a possible implementation manner, the mode of the first sub-service is a try-confirm-cancel TCC mode, and the mode of the second sub-service is a SAGA mode.

[0029] In a second aspect, an embodiment of the present application provides a multi-mode service processing device, including: an acquisition module, a first processing module, and a second processing module, wherein:

[0030] The acquisition module is used to acquire a service processing request, where the service processing request is used to request processing of a first service, where the first service includes at least one first sub-service and at least one second sub-service, and the first sub-service and the second sub-service have different modes;

[0031] The first processing module is used to pre-process each first sub-service respectively, and the pre-processing is used to ensure that the result of executing the first sub-service is successful;

[0032] The second processing module is configured to, if the first processing module successfully pre-processes the at least one first sub-service, perform service processing on the at least one second sub-service to obtain a second execution result corresponding to the at least one second sub-service;

[0033] The first processing module is further used to perform execution processing or rollback processing on each first sub-service according to the second execution result, so as to obtain a first execution result corresponding to each first sub-service, and the first execution result is the same as the second execution result.

[0034] In a possible implementation manner, the first processing module is specifically configured to:

[0035] If the second execution result is successful execution, then each first sub-business is executed separately to obtain a first execution result corresponding to each first sub-business, and the first execution result corresponding to each first sub-business is successful execution;

[0036] If the second execution result is execution failure, each first sub-business is rolled back to obtain the first execution result corresponding to each first sub-business, and the first execution result corresponding to each first sub-business is execution failure.

[0037] In a possible implementation manner, for any first sub-service, the first processing module is specifically configured to:

[0038] The preprocessing of the first sub-service is rolled back to obtain a first execution result corresponding to the first sub-service, and the state of the first sub-service after the rollback is the same as the state of the first sub-service before the preprocessing.

[0039] In a possible implementation manner, if the second execution result is execution failure, the second processing module is further configured to:

[0040] Determining a second sub-service that has been service-processed in the at least one second sub-service;

[0041] Perform reverse business processing on the second sub-business that has been processed.

[0042] In a possible implementation manner, the second processing module is specifically configured to:

[0043] Determining an execution order of the at least one second sub-service;

[0044] The at least one second sub-business is processed in accordance with the execution order until each second sub-business is executed successfully, and the second execution result is determined to be a successful execution, or the second execution result is determined to be a failed execution when it is determined that any second sub-business in the at least one second sub-business fails to execute.

[0045] In a possible implementation manner, for any second sub-service, a state of the second sub-service after the reverse service processing is performed is the same as a state of the second sub-service before the service processing is performed.

[0046] In a possible implementation manner, for any first sub-service, the first processing module is specifically configured to:

[0047] Obtaining a service parameter corresponding to the first sub-service in the service processing request;

[0048] Determining whether the service parameters meet the service requirements corresponding to the first sub-service;

[0049] When it is determined that the service parameter meets the service requirement corresponding to the first sub-service, service resources are allocated to the first sub-service, where the service resources are resources required for executing the first sub-service.

[0050] In a possible embodiment, the first processing module is also used to perform rollback processing on the first sub-service that has undergone the preprocessing if the first processing module fails to preprocess any one of the at least one first sub-service; wherein the state of the first sub-service after the rollback processing is the same as the state of the first sub-service before the preprocessing.

[0051] In a possible implementation manner, the mode of the first sub-service is a try-confirm-cancel TCC mode, and the mode of the second sub-service is a SAGA mode.

[0052] In a third aspect, an embodiment of the present application provides a multi-mode service processing device, including: a processor and a memory;

[0053] The memory stores computer-executable instructions;

[0054] The processor executes the computer-executable instructions stored in the memory, so that the processor executes

[0055] A multi-mode business processing method as described in any one of the first aspects.

[0056] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer execution instructions, which, when executed by a processor, are used to implement the multi-mode business processing method described in any one of the first aspects.

[0057] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the multi-mode business processing method shown in any one of the first aspects.

[0058] The multi-mode business processing method, device and equipment provided by the embodiment of the present application, if the distributed business includes sub-businesses of the TCC mode and sub-businesses of the SAGA mode, the sub-businesses of the TCC mode can be pre-processed first, and then the sub-businesses of the SAGA mode can be processed after the pre-processing of the sub-businesses of the TCC mode is successful. If the execution result of the sub-business of the SAGA mode is successful, the sub-business of the TCC mode is executed. Since the sub-business of the TCC mode has been pre-processed, the execution processing of the sub-business of the TCC mode will definitely be successful, thereby ensuring the consistency of business processing. If the execution result of the sub-business of the SAGA mode is failure, the sub-business of the TCC mode is rolled back to roll back the sub-business of the TCC mode to the initial state. Therefore, the execution of the sub-business of the TCC mode is also failed, thereby ensuring the consistency of business processing. BRIEF DESCRIPTION OF THE DRAWINGS

[0059] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0060] Figure 1 An architecture diagram of a distributed business system provided in an embodiment of the present application;

[0061] Figure 2 A flowchart of a multi-mode business processing method provided in an embodiment of the present application;

[0062] Figure 3 A flowchart of a multi-mode service processing method provided in an embodiment of the present application;

[0063] Figure 4 An architecture diagram of a distributed service provided in an embodiment of the present application;

[0064] Figure 5 A schematic diagram of a processing process provided in an embodiment of the present application;

[0065] Figure 6 A schematic diagram of a processing process provided in an embodiment of the present application;

[0066] Figure 7 A schematic diagram of the structure of a multi-mode service processing device provided in an embodiment of the present application;

[0067] Figure 8 A schematic diagram of the structure of a multi-mode business processing device is provided for an embodiment of the present application. DETAILED DESCRIPTION

[0068] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0069] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can, for example, be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0070] To facilitate understanding, the concepts involved in the embodiments of the present application are first described in detail.

[0071] TCC mode: TCC mode includes three types of processing, namely pre-processing, execution processing and rollback processing. Among them, pre-processing refers to the try operation (try operation), execution processing refers to the confirmation operation (Confirm operation), and rollback processing refers to the cancel operation (Cancel operation). The following describes the three types of processing in TCC mode respectively.

[0072] Preprocessing: Preprocessing can usually include inspection processing and business resource allocation processing. Inspection processing is used to check whether the business request meets the business requirements of the sub-business system. For example, assuming that the business request is a request to deduct an amount of 1 from account 1, the inspection processing may include: determining whether account 1 exists, determining whether the password of account 1 entered by the user is correct, and whether the current balance in account 1 is greater than the amount 1. Business resource allocation processing is used to allocate the resources required for execution processing to the sub-business system to ensure that the result of the execution processing is a successful execution. For example, assuming that the business request is a request to deduct an amount of 1 from account 1, the business resource allocation processing may include: freezing the amount of 1 in account 1 to ensure that the amount of 1 can be successfully deducted from account 1 in subsequent execution processing.

[0073] Execution processing: Execution processing is used to complete business logic processing. For example, if the business request is to deduct an amount of 1 from account 1, then execution processing can achieve the deduction of an amount of 1 from account 1. In TCC mode, if preprocessing is successful, execution processing must be successful.

[0074] Rollback processing: It is used to roll back the processing that has been executed when the preprocessing or execution processing fails, so as to cancel the operation that has been performed and release the business resources allocated in the preprocessing stage.

[0075] SAGA mode: SAGA mode is a distributed transaction implementation mode based on compensation transactions. In SAGA mode, the distributed business includes several sub-businesses, each of which corresponds to business processing and reverse business processing. Business processing can also be called forward business processing, and reverse business processing can also be called reverse compensation processing. When the distributed business of SAGA mode is executed, the forward business processing of each sub-business is executed in turn. If the forward business processing of all sub-businesses is successfully executed, the distributed business execution is completed. If the forward business processing of any sub-business fails to execute, the reverse business processing (reverse compensation processing) is performed on the sub-business that has already performed the forward business processing, so that the sub-business that has already performed the forward business processing returns to the initial state.

[0076] Business consistency of distributed business: A distributed business includes multiple sub-businesses. Business consistency means that the processing results of each sub-business are the same. The processing results of the multiple sub-businesses are either all executed successfully or all executed failed.

[0077] Next, combine Figure 1 , the distributed business system involved in the embodiments of the present application is described.

[0078] Figure 1 This is an architecture diagram of the distributed business system provided in the embodiment of this application. Figure 1 , the distributed business system includes a business manager and multiple sub-business systems. Distributed business includes multiple sub-businesses, and a sub-business system can be used to process a sub-business. The business manager is used to call and manage the sub-business system to ensure that the processing results of each sub-business system for its corresponding sub-business are consistent. A sub-business system can be deployed in a virtual machine, and different virtual machines can be deployed on the same physical device or on different physical devices. The business manager can be deployed on the same physical device as the sub-business system, or on a different physical device.

[0079] Optionally, if the sub-business system is in TCC mode, the sub-business system may include three interfaces: an interface for preprocessing, an interface for execution processing, and an interface for rollback processing. Accordingly, the business manager may call the interface of the sub-business system to enable the sub-business system to perform preprocessing, execution processing, or rollback processing.

[0080] Optionally, if the sub-business system is in SAGA mode, the sub-business system may include two interfaces: an interface for business processing and an interface for reverse business processing. Accordingly, the business manager may call the interface of the sub-business system to enable the sub-business system to perform business processing or reverse business processing.

[0081] In the related art, if the modes of the sub-business systems in the business system are different, that is, the modes of the sub-businesses included in the distributed business are different, it is impossible to ensure that the processing results of the sub-businesses in the distributed business are consistent, that is, the business consistency of the distributed business cannot be guaranteed, which leads to poor reliability of business processing.

[0082] In order to solve the above technical problems, in the embodiment of the present disclosure, if the distributed service includes the sub-service of the TCC mode and the sub-service of the SAGA mode, the sub-service of the TCC mode can be pre-processed first, and then the sub-service of the SAGA mode can be processed after the pre-processing of the sub-service of the TCC mode is successful. If the execution result of the sub-service of the SAGA mode is successful, the sub-service of the TCC mode is executed. Since the sub-service of the TCC mode has been pre-processed, the execution of the sub-service of the TCC mode will definitely be successful, thereby ensuring the consistency of the service processing. If the execution result of the sub-service of the SAGA mode is failure, the sub-service of the TCC mode is rolled back to roll back the sub-service of the TCC mode to the initial state. Therefore, the execution of the sub-service of the TCC mode is also failed, thereby ensuring the consistency of the service processing.

[0083] The following specific embodiments are used to describe the technical solutions shown in the present application in detail. The following embodiments can exist independently or in combination with each other, and the same or similar contents will not be described repeatedly in different embodiments.

[0084] Figure 2 A flowchart of a multi-mode service processing method provided in an embodiment of the present application. Figure 2 , the method may include:

[0085] S201: Obtain a business processing request.

[0086] The execution subject of the embodiment of the present application may be a distributed business system. Some steps in the embodiment of the present application may be executed by a business manager in the distributed business system, and some steps may be executed by the business manager calling a sub-business system.

[0087] Optionally, a business manager in the distributed business system may obtain the business processing request.

[0088] The service processing request is used to request processing of a first service, the first service includes at least one first sub-service and at least one second sub-service, and the first sub-service and the second sub-service have different modes. The mode of the first sub-service is TCC mode, and the mode of the second sub-service is SAGA mode.

[0089] The business processing request may be a business processing request from a client. For example, the business processing request may be a request to transfer a predetermined amount in account 1 to account 2. Assuming that the business processing request corresponds to a first business, the first business includes the following two sub-businesses: sub-business 1: deducting a predetermined amount from account 1, and sub-business 2: depositing a predetermined amount into account 2.

[0090] S202: Preprocess each first sub-service respectively.

[0091] Optionally, after the service manager obtains the service processing request, the service manager may call corresponding sub-service systems respectively, so that the sub-service systems process the corresponding first sub-service.

[0092] The preprocessing is used to ensure that the result of executing the first sub-service is successful, that is, if the preprocessing of the first sub-service is successful, the execution of the first sub-service will also be successful.

[0093] Preprocessing may include inspection processing and allocation processing of business resources, and the inspection processing is used to detect whether the business parameters in the business processing request meet the business requirements corresponding to the first sub-business. The allocation processing of business resources is used to divide the business resources required for executing the first sub-business. If the inspection processing of the first sub-business is successful, and the allocation processing is successful, the preprocessing of the first sub-business is successful. After the preprocessing of the first sub-business is successful, the first sub-business has met the necessary conditions for the successful execution processing. Therefore, after the preprocessing of the first sub-business is successful, it is assumed that the execution processing of the first sub-business must also be successful.

[0094] The process of preprocessing each first sub-business is the same. The following is an explanation of the process of preprocessing any first sub-business: obtaining business parameters corresponding to the first sub-business in the business processing request, determining whether the business parameters meet the business requirements corresponding to the first sub-business (inspection processing), and when it is determined that the business parameters meet the business requirements corresponding to the first sub-business, allocating business resources to the first sub-business, and the business resources are the resources required to execute the first sub-business (business resource allocation processing).

[0095] For example, assuming that the first sub-service is: deducting a preset amount from account 1, the service request may include account 1, the password of account 1, and the preset amount, and the check process may include: checking whether account 1 exists, checking whether the password of account 1 is correct, and checking whether the amount in account 1 is greater than or equal to the preset amount. The allocation process of service resources may include: freezing the preset amount in account 1.

[0096] Optionally, at least one first sub-service may be preprocessed in parallel or sequentially. For example, a processing sequence of at least one first sub-service may be obtained, and the at least one first sub-service may be preprocessed according to the processing sequence.

[0097] S203: If the pre-processing of the at least one first sub-service is successful, perform service processing on the at least one second sub-service to obtain a second execution result corresponding to the at least one second sub-service.

[0098] The service manager may determine whether the preprocessing of the first sub-service is successful. After the service manager determines that the preprocessing of at least one first sub-service is successful, the service manager may call the corresponding sub-service system so that the sub-service system performs service processing on the corresponding second sub-service.

[0099] If the pre-processing of each first sub-service is successful, then service processing is performed on at least one second sub-service.

[0100] The second execution result corresponding to the at least one second sub-business can be obtained by performing business processing on at least one second sub-business in the following manner: determining the execution order of at least one second sub-business, and performing business processing on at least one second sub-business according to the execution order, until each second sub-business is executed successfully, and determining the second execution result as successful execution, or until it is determined that the execution of any second sub-business in the at least one second sub-business fails, and determining the second execution result as failed execution.

[0101] For example, assuming that at least one second sub-business includes sub-business 1, sub-business 2, sub-business 3 and sub-business 4, and the execution order of the four sub-businesses is: sub-business 1, sub-business 2, sub-business 3 and sub-business 4, the four sub-businesses can be processed in sequence. Assuming that the business processing of the four sub-businesses is successful, the second execution results corresponding to the four sub-businesses are successful execution. Assuming that the business processing of sub-business 1 and sub-business 2 is successful, and the business processing of sub-business 3 fails, the business processing of sub-business 4 will no longer continue, and the second execution result is determined to be execution failure. After determining that the execution of the second execution result has failed, reverse business processing can be performed on sub-business 1 and sub-business 2 to make sub-business 1 and sub-business 2 roll back to the initial state (the state before business processing). If part of the business processing is also performed on sub-business 3, the part of the business processing that has been performed in business 3 is also rolled back.

[0102] For any second sub-service, the state of the second sub-service after the reverse service processing is the same as the state of the second sub-service before the service processing.

[0103] S204: Perform execution processing or rollback processing on each first sub-service according to the second execution result, and obtain a first execution result corresponding to each first sub-service.

[0104] The first execution result is the same as the second execution result, the first execution result and the second execution result are both successful, or the first execution result and the second execution result are both failed.

[0105] If the second execution result is successful, each first sub-business is executed separately to obtain the first execution result corresponding to each first sub-business, and the first execution result corresponding to each first sub-business is successful. In this case, both the first execution result and the second execution result are successful.

[0106] If the second execution result is execution failure, each first sub-service is rolled back to obtain the first execution result corresponding to each first sub-service, and the first execution result corresponding to each first sub-service is execution failure. In this case, both the first execution result and the second execution result are execution failures.

[0107] The first sub-service may be rolled back in the following manner: roll back pre-processing of the first sub-service to obtain a first execution result corresponding to the first sub-service, wherein the state of the first sub-service after rollback is the same as the state of the first sub-service before pre-processing.

[0108] exist Figure 2In the illustrated embodiment, if the distributed service includes a sub-service of the TCC mode and a sub-service of the SAGA mode, the sub-service of the TCC mode may be pre-processed first, and then the sub-service of the SAGA mode may be processed after the pre-processing of the sub-service of the TCC mode is successful. If the execution result of the sub-service of the SAGA mode is a successful execution, the sub-service of the TCC mode is executed. Since the sub-service of the TCC mode has been pre-processed, the execution of the sub-service of the TCC mode will definitely be successful, thereby ensuring the consistency of the service processing. If the execution result of the sub-service of the SAGA mode is an execution failure, the sub-service of the TCC mode is rolled back to roll back the sub-service of the TCC mode to the initial state. Therefore, the execution of the sub-service of the TCC mode is also an execution failure, thereby ensuring the consistency of the service processing.

[0109] Based on any of the above embodiments, Figure 3 The illustrated embodiment provides a detailed description of the multi-mode service processing process.

[0110] Figure 3 This is a flowchart of a multi-mode service processing method provided in an embodiment of the present application. Figure 3 , the method may include:

[0111] S301: Obtain a business processing request.

[0112] S302: Preprocess each first sub-service respectively.

[0113] It should be noted that the execution process of S301-S302 can refer to the execution process of S201-S202, and will not be repeated here.

[0114] S303: Determine whether preprocessing of each first sub-service is successful.

[0115] If yes, execute S305.

[0116] If not, execute S304.

[0117] S304: Roll back the pre-processed first sub-service.

[0118] After the pre-processed first sub-business is rolled back, the second sub-business is no longer processed. In this case, both the execution results of the first sub-business and the execution results of the second sub-business are execution failures.

[0119] S305: Perform service processing on at least one second sub-service to obtain a second execution result corresponding to the at least one second sub-service.

[0120] S306: Determine whether a second execution result corresponding to at least one second sub-service is successful.

[0121] If yes, execute S307.

[0122] If not, execute S308.

[0123] If each of the at least one second sub-service is successfully executed, the second execution result is determined to be execution success. If any of the at least one second sub-service fails to be executed, the second execution result is determined to be execution failure.

[0124] It should be noted that the execution process of S306 can refer to the execution process of S203, which will not be described in detail here.

[0125] S307 : Execute each first sub-service respectively to obtain a first execution result corresponding to each first sub-service.

[0126] If each second sub-service is successfully executed, each first sub-service is executed, and since the first sub-service has been pre-processed, the first execution result of the execution of the first sub-service is successful. That is, the execution results of the first sub-service and the second sub-service are both successful, ensuring the consistency of the execution results of the first sub-service and the second sub-service.

[0127] S308: Determine a second sub-service that has been processed in at least one second sub-service.

[0128] The second sub-business that has been processed includes: a second sub-business that has completed the business processing and the execution result is successful execution, and a second sub-business that has completed part of the business processing and the execution result is failed execution.

[0129] S309: Perform reverse business processing on the second sub-business that has been processed.

[0130] The reverse business process refers to canceling the process that has been executed by the second sub-business. The reverse business process is performed on the second sub-business, so that the state of the second sub-business can be rolled back to the initial state, and the initial state is the state before the business process is performed.

[0131] For example, assuming that the business processing of the second sub-business is: depositing a predetermined amount into account 1, then the reverse business processing of the second sub-business is: deducting the predetermined amount from account 1.

[0132] S310 . Perform rollback processing on each first sub-service respectively to obtain a first execution result corresponding to each first sub-service.

[0133] If the processing of the second sub-service fails, each first sub-service is rolled back to make the state of each first sub-service roll back to the initial state. Since only the first sub-service is pre-processed, rolling back the first sub-service means rolling back the pre-processing of the first sub-service, that is, canceling the pre-processing of the first sub-service.

[0134] For example, the pre-processing of the first sub-business includes: freezing the reserved amount in Account 1 , and the rollback processing of the first sub-business refers to unfreezing the reserved amount in Account 1 .

[0135] When the second sub-service fails to be processed, the first sub-service is also rolled back, so that the first execution result service corresponding to the first sub-service fails to execute. That is, the execution result of the first sub-service and the execution result of the second sub-service are both execution failures, ensuring the consistency of the execution results of the first sub-service and the second sub-service.

[0136] exist Figure 3 In the illustrated embodiment, if the distributed service includes a sub-service of the TCC mode and a sub-service of the SAGA mode, the sub-service of the TCC mode may be pre-processed first, and then the sub-service of the SAGA mode may be processed after the pre-processing of the sub-service of the TCC mode is successful. If the execution result of the sub-service of the SAGA mode is a successful execution, the sub-service of the TCC mode is executed. Since the sub-service of the TCC mode has been pre-processed, the execution of the sub-service of the TCC mode will definitely be successful, thereby ensuring the consistency of the service processing. If the execution result of the sub-service of the SAGA mode is an execution failure, the sub-service of the TCC mode is rolled back to roll back the sub-service of the TCC mode to the initial state. Therefore, the execution of the sub-service of the TCC mode is also an execution failure, thereby ensuring the consistency of the service processing.

[0137] Based on any of the above embodiments, Figure 4-Figure 6 , the above multi-mode business processing method is explained through specific examples.

[0138] Figure 4 This is a diagram of the architecture of the distributed service provided in the embodiment of this application. Figure 4, assuming that the distributed service is that the user purchases financial products on a third-party platform through account 1, the distributed service includes 5 sub-services, which are: deducting a predetermined amount from account 1 (sub-service 1), depositing the predetermined amount into a third-party account (sub-service 2), executing the transaction process (sub-service 3), deducting a predetermined amount from a third-party account (sub-service 4), and depositing a predetermined amount into account 2 (sub-service 5). Among them, sub-service 1, sub-service 2, and sub-service 3 are TCC modes, and sub-service 4 and sub-service 5 are SAGA modes.

[0139] Next, combine Figure 5-Figure 6 ,right Figure 4 The processing process of the distributed service shown is explained.

[0140] Figure 5 A schematic diagram of a processing process provided by an embodiment of the present application. Figure 5 When processing distributed services, first pre-process sub-service 1, sub-service 2, and sub-service 3 respectively. Assuming that the pre-processing of sub-service 1, sub-service 2, and sub-service 3 is successful, then the service processing of sub-service 4 and sub-service 5 is performed. If the service processing of sub-service 4 and sub-service 5 is successful, that is, the execution results corresponding to sub-service 4 and sub-service 5 are both successful, then the execution processing of sub-service 1, sub-service 2, and sub-service 3 is performed respectively. Since sub-service 1-sub-service 3 has been pre-processed, the execution result of the execution processing of sub-service 1-sub-service 3 must be successful. That is, the execution results of sub-service 1-sub-service 5 are all successful, which ensures the consistency of service execution.

[0141] Figure 6 A schematic diagram of a processing process provided by an embodiment of the present application. Figure 6 When processing distributed services, sub-service 1, sub-service 2, and sub-service 3 are pre-processed respectively. Assuming that the pre-processing of sub-service 1, sub-service 2, and sub-service 3 is successful, then the business processing of sub-service 4 and sub-service 5 is performed. Assuming that the business processing of sub-service 4 is successful, and the business processing of sub-service 5 fails, then the reverse business processing of sub-service 4 is continued, so that the execution results of sub-service 4 and sub-service 5 are both execution failures. After the execution of sub-service 4 and sub-service 5 fails, the rollback processing is performed on sub-service 1-sub-service 3 respectively, so that the execution results of sub-service 1-sub-service 3 are all execution failures. That is, the execution results of sub-service 1-sub-service 5 are all successful, which ensures the consistency of business execution.

[0142] Figure 7 A schematic diagram of the structure of a multi-mode service processing device provided in an embodiment of the present application. Figure 7The multi-mode service processing device 10 may include: an acquisition module 11, a first processing module 12 and a second processing module 13, wherein:

[0143] The acquisition module 11 is used to acquire a service processing request, where the service processing request is used to request processing of a first service, where the first service includes at least one first sub-service and at least one second sub-service, and the first sub-service and the second sub-service have different modes;

[0144] The first processing module 12 is used to pre-process each first sub-service respectively, and the pre-processing is used to ensure that the result of executing the first sub-service is successful;

[0145] The second processing module 13 is configured to, if the first processing module successfully pre-processes the at least one first sub-service, perform service processing on the at least one second sub-service to obtain a second execution result corresponding to the at least one second sub-service;

[0146] The first processing module 12 is further used to perform execution processing or rollback processing on each first sub-service according to the second execution result, so as to obtain a first execution result corresponding to each first sub-service, and the first execution result is the same as the second execution result.

[0147] The multi-mode business processing device provided in the embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be repeated here.

[0148] In a possible implementation manner, the first processing module 12 is specifically configured to:

[0149] If the second execution result is successful execution, then each first sub-business is executed separately to obtain a first execution result corresponding to each first sub-business, and the first execution result corresponding to each first sub-business is successful execution;

[0150] If the second execution result is execution failure, each first sub-business is rolled back to obtain the first execution result corresponding to each first sub-business, and the first execution result corresponding to each first sub-business is execution failure.

[0151] In a possible implementation manner, for any first sub-service, the first processing module 12 is specifically configured to:

[0152] The preprocessing of the first sub-service is rolled back to obtain a first execution result corresponding to the first sub-service, and the state of the first sub-service after the rollback is the same as the state of the first sub-service before the preprocessing.

[0153] In a possible implementation manner, if the second execution result is execution failure, the second processing module 12 is further configured to:

[0154] Determining a second sub-service that has been service-processed in the at least one second sub-service;

[0155] Perform reverse business processing on the second sub-business that has been processed.

[0156] In a possible implementation manner, the second processing module 12 is specifically configured to:

[0157] Determining an execution order of the at least one second sub-service;

[0158] The at least one second sub-business is processed in accordance with the execution order until each second sub-business is executed successfully, and the second execution result is determined to be a successful execution, or the second execution result is determined to be a failed execution when it is determined that any second sub-business in the at least one second sub-business fails to execute.

[0159] In a possible implementation manner, for any second sub-service, a state of the second sub-service after the reverse service processing is performed is the same as a state of the second sub-service before the service processing is performed.

[0160] In a possible implementation manner, for any first sub-service, the first processing module 12 is specifically configured to:

[0161] Obtaining a service parameter corresponding to the first sub-service in the service processing request;

[0162] Determining whether the service parameters meet the service requirements corresponding to the first sub-service;

[0163] When it is determined that the service parameter meets the service requirement corresponding to the first sub-service, service resources are allocated to the first sub-service, where the service resources are resources required for executing the first sub-service.

[0164] In a possible embodiment, the first processing module 12 is also used to perform rollback processing on the first sub-service that has undergone the preprocessing if the first processing module 12 fails to preprocess any one of the at least one first sub-service; wherein the state of the first sub-service after the rollback processing is the same as the state of the first sub-service before the preprocessing.

[0165] In a possible implementation manner, the mode of the first sub-service is a try-confirm-cancel TCC mode, and the mode of the second sub-service is a SAGA mode.

[0166] The multi-mode business processing device provided in the embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be repeated here.

[0167] Figure 8 A schematic diagram of the structure of a multi-mode service processing device is provided for an embodiment of the present application. Figure 8 The multi-mode service processing device 20 may include a processor 21 and a memory 22. Exemplarily, the processor 21 and the memory 22 are interconnected via a bus 23.

[0168] The memory 21 stores computer-executable instructions;

[0169] The processor 21 executes the computer execution instructions stored in the memory 22, so that the processor 21 executes the multi-mode business processing method as described in any one of the first aspects.

[0170] Figure 8 The multi-mode business processing device shown in the embodiment can execute the technical solution shown in the above method embodiment, and its implementation principles and beneficial effects are similar, which will not be repeated here.

[0171] An embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the above-mentioned multi-mode business processing method.

[0172] The embodiment of the present application may also provide a computer program product, including a computer program, which, when executed by a processor, can implement the above-mentioned multi-mode business processing method.

[0173] All or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a readable memory. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned memory (storage medium) includes: read-only memory (English: read-only memory, abbreviated: ROM), RAM, flash memory, hard disk, solid state drive, magnetic tape (English: magnetic tape), floppy disk (English: floppy disk), optical disc (English: optical disc) and any combination thereof.

[0174] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processing unit of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processing unit of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0175] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0176] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0177] Obviously, those skilled in the art can make various changes and modifications to the embodiments of the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the embodiments of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

[0178] In the present application, the term "include" and its variations may refer to non-restrictive inclusion; the term "or" and its variations may refer to "and / or". The terms "first", "second", etc. in this application are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. In the present application, "plurality" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B may mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the previously associated objects are in an "or" relationship.

Claims

1. A multi-mode business processing method, characterized in that: include: Obtain a service processing request, where the service processing request is used to request processing of a first service, where the first service includes at least one first sub-service and at least one second sub-service, where the first sub-service and the second sub-service have different modes; the mode of the first sub-service is a try-confirm-cancel TCC mode, and the mode of the second sub-service is a SAGA mode; Preprocessing each first sub-service respectively, wherein the preprocessing is used to ensure that the result of executing the first sub-service is successful; If the preprocessing of the at least one first sub-service is successful, performing service processing on the at least one second sub-service to obtain a second execution result corresponding to the at least one second sub-service; According to the second execution result, each first sub-service is executed or rolled back to obtain a first execution result corresponding to each first sub-service, and the first execution result is the same as the second execution result.

2. The method according to claim 1, characterized in that According to the second execution result, each first sub-service is respectively executed or rolled back to obtain a first execution result corresponding to each first sub-service, including: If the second execution result is successful execution, then each first sub-business is executed separately to obtain a first execution result corresponding to each first sub-business, and the first execution result corresponding to each first sub-business is successful execution; If the second execution result is execution failure, each first sub-business is rolled back to obtain the first execution result corresponding to each first sub-business, and the first execution result corresponding to each first sub-business is execution failure.

3. The method according to claim 2, characterized in that For any first sub-service, performing rollback processing on the first sub-service to obtain a first execution result corresponding to the first sub-service includes: The preprocessing of the first sub-service is rolled back to obtain a first execution result corresponding to the first sub-service, and the state of the first sub-service after the rollback is the same as the state of the first sub-service before the preprocessing.

4. The method according to claim 2, characterized in that: If the second execution result is execution failure, the method further includes: Determining a second sub-service that has been service-processed in the at least one second sub-service; Perform reverse business processing on the second sub-business that has been processed.

5. The method according to claim 4, characterized in that Performing a service on the at least one second sub-service to obtain a second execution result corresponding to the at least one second sub-service includes: Determining an execution order of the at least one second sub-service; The at least one second sub-business is processed in accordance with the execution order until each second sub-business is executed successfully, and the second execution result is determined to be a successful execution, or the second execution result is determined to be a failed execution when it is determined that any second sub-business in the at least one second sub-business fails to execute.

6. The method according to claim 5, characterized in that For any second sub-service, the state of the second sub-service after the reverse service processing is performed is the same as the state of the second sub-service before the service processing is performed.

7. The method according to any one of claims 1 to 6, characterized in that: For any first sub-service, pre-processing the first sub-service includes: Obtaining a service parameter corresponding to the first sub-service in the service processing request; Determining whether the service parameters meet the service requirements corresponding to the first sub-service; When it is determined that the service parameter meets the service requirement corresponding to the first sub-service, service resources are allocated to the first sub-service, where the service resources are resources required for executing the first sub-service.

8. The method according to any one of claims 1 to 6, characterized in that: If preprocessing of any first sub-service of the at least one first sub-service fails, the method further includes: Rollback processing is performed on the first sub-service that has undergone the preprocessing; wherein the state of the first sub-service after the rollback processing is the same as the state of the first sub-service before the preprocessing.

9. A multi-mode service processing device, characterized in that: include: An acquisition module, a first processing module and a second processing module, wherein: The acquisition module is used to acquire a service processing request, where the service processing request is used to request processing of a first service, where the first service includes at least one first sub-service and at least one second sub-service, where the first sub-service and the second sub-service have different modes; the mode of the first sub-service is a try-confirm-cancel TCC mode, and the mode of the second sub-service is a SAGA mode; The first processing module is used to pre-process each first sub-service respectively, and the pre-processing is used to ensure that the result of executing the first sub-service is successful; The second processing module is configured to, if the first processing module successfully pre-processes the at least one first sub-service, perform service processing on the at least one second sub-service to obtain a second execution result corresponding to the at least one second sub-service; The first processing module is further used to perform execution processing or rollback processing on each first sub-service according to the second execution result, so as to obtain a first execution result corresponding to each first sub-service, and the first execution result is the same as the second execution result.

10. A multi-mode service processing device, characterized in that: include: Processor and memory; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory, so that the processor executes the multi-mode business processing method according to any one of claims 1 to 8.

11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the multi-mode business processing method according to any one of claims 1 to 8 when executed by a processor.

12. A computer program product, characterized in that It comprises a computer program, which, when executed by a processor, implements the multi-mode business processing method shown in any one of claims 1 to 8.