CN113065967A - Multi-mode service processing method, device and equipment - Google Patents

Multi-mode service processing method, device and equipment Download PDF

Info

Publication number
CN113065967A
CN113065967A CN202110538092.9A CN202110538092A CN113065967A CN 113065967 A CN113065967 A CN 113065967A CN 202110538092 A CN202110538092 A CN 202110538092A CN 113065967 A CN113065967 A CN 113065967A
Authority
CN
China
Prior art keywords
service
sub
processing
execution result
execution
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110538092.9A
Other languages
Chinese (zh)
Inventor
梁向东
刘浩
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Agricultural Bank of China
Original Assignee
Agricultural Bank of China
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Agricultural Bank of China filed Critical Agricultural Bank of China
Priority to CN202110538092.9A priority Critical patent/CN113065967A/en
Publication of CN113065967A publication Critical patent/CN113065967A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/02Banking, e.g. interest calculation or account maintenance

Landscapes

  • Business, Economics & Management (AREA)
  • Accounting & Taxation (AREA)
  • Finance (AREA)
  • Engineering & Computer Science (AREA)
  • Development Economics (AREA)
  • Economics (AREA)
  • Marketing (AREA)
  • Strategic Management (AREA)
  • Technology Law (AREA)
  • Physics & Mathematics (AREA)
  • General Business, Economics & Management (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Hardware Redundancy (AREA)

Abstract

The embodiment of the application provides a multi-mode service processing method, a device and equipment, wherein the method comprises the following steps: acquiring a service processing request, wherein the service processing request is used for requesting to process a first service, the first service comprises at least one first sub-service and at least one second sub-service, and the modes of the first sub-service and the second sub-service are different; respectively preprocessing each first sub-service, wherein the preprocessing is used for enabling the execution processing result of the first sub-service to be 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; and respectively performing execution processing or backspacing processing on each first sub-service according to the second execution result to obtain a first execution result corresponding to each first sub-service, wherein the first execution result is the same as the second execution result. The reliability of service processing is improved.

Description

Multi-mode service processing method, device and equipment
Technical Field
The present invention relates to computer technologies, and in particular, to a method, an apparatus, and a device for processing a multi-mode service.
Background
The distributed service system can process distributed services, the distributed service system comprises a plurality of sub-service systems, the distributed services comprise a plurality of sub-services, and one sub-service system is generally used for processing one sub-service.
Currently, the sub-business system may be a SAGA mode or a Try-Confirm-Cancel (TCC) mode for handling long live transactions. When the distributed service processing system processes the distributed service, it is necessary to ensure that the processing results of each sub-service in the distributed service are consistent, that is, either each sub-service is successfully processed or each sub-service is unsuccessfully processed. In the related art, in order to ensure that the processing results of each sub-service in the distributed service are consistent, the mode of each sub-service system in the distributed service system needs to be set to be the same mode, and if the modes of each sub-service system in the service system are different, the processing results of each sub-service in the distributed service cannot be ensured to be consistent, so that the reliability of service processing is poor.
Disclosure of Invention
The embodiment of the application provides a multi-mode service processing method, device and equipment. The reliability of the service processing is improved.
In a first aspect, an embodiment of the present application provides a multi-mode service processing method, including:
acquiring a service processing request, wherein the service processing request is used for requesting to process a first service, the first service comprises at least one first sub-service and at least one second sub-service, and the modes of the first sub-service and the second sub-service are different;
respectively preprocessing each first sub-service, wherein the preprocessing is used for enabling the execution processing result of the first sub-service to be successful;
if the at least one first sub-service is successfully preprocessed, 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;
and respectively performing execution processing or backspacing processing on each first sub-service according to the second execution result to obtain a first execution result corresponding to each first sub-service, wherein the first execution result is the same as the second execution result.
In a possible implementation manner, performing execution processing or fallback processing on each first sub-service according to the second execution result to obtain a first execution result corresponding to each first sub-service includes:
if the second execution result is successful, performing execution processing on each first sub-service respectively to obtain a first execution result corresponding to each first sub-service, wherein the first execution result corresponding to each first sub-service is successful;
and if the second execution result is execution failure, performing rollback processing on each first sub-service respectively to obtain a first execution result corresponding to each first sub-service, wherein the first execution result corresponding to each first sub-service is execution failure.
In one possible embodiment, for any one of the first sub-services; performing fallback processing on the first sub-service to obtain a first execution result corresponding to the first sub-service, including:
and performing rollback processing on the preprocessing 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 the rollback processing is the same as the state of the first sub-service before the preprocessing.
In a possible implementation manner, if the second execution result is an execution failure, the method further includes:
determining a second sub-service which is subjected to service processing in the at least one second sub-service;
and performing inverse service processing on the second sub-service subjected to the service processing.
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:
determining an execution order of the at least one second sub-service;
and performing service processing on the at least one second sub-service according to the execution sequence until each second sub-service is successfully executed, and determining that the second execution result is successful, or determining that the second execution result is failed until any second sub-service in the at least one second sub-service is unsuccessfully executed.
In a possible implementation manner, for any one second sub-service, a state of the second sub-service after the inverse service processing is performed is the same as a state of the second sub-service before the service processing is performed.
In one possible embodiment, for any one of the first sub-services; preprocessing the first sub-service, including:
acquiring a service parameter corresponding to the first sub-service in the service processing request;
judging whether the service parameters meet the service requirements corresponding to the first sub-service;
and when the service parameter is determined to meet the service requirement corresponding to the first sub-service, allocating service resources to the first sub-service, wherein the service resources are resources required for executing the processing on the first sub-service.
In a possible implementation manner, if the preprocessing fails for any one of the at least one first sub-service, the method further includes:
performing rollback processing on the preprocessed 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.
In one possible embodiment, the mode of the first sub-service is an attempt-acknowledge-cancel TCC mode, and the mode of the second sub-service is a SAGA mode.
In a second aspect, an embodiment of the present application provides a multi-mode service processing apparatus, including: an acquisition module, a first processing module and a second processing module, wherein,
the acquiring module is configured 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;
the first processing module is used for respectively preprocessing each first sub-service, and the preprocessing is used for enabling the result of executing the first sub-services to be successful;
the second processing module is configured to, if the first processing module successfully preprocesses 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 configured 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, where the first execution result is the same as the second execution result.
In a possible implementation manner, the first processing module is specifically configured to:
if the second execution result is successful, performing execution processing on each first sub-service respectively to obtain a first execution result corresponding to each first sub-service, wherein the first execution result corresponding to each first sub-service is successful;
and if the second execution result is execution failure, performing rollback processing on each first sub-service respectively to obtain a first execution result corresponding to each first sub-service, wherein the first execution result corresponding to each first sub-service is execution failure.
In one possible embodiment, for any one of the first sub-services; the first processing module is specifically configured to:
and performing rollback processing on the preprocessing 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 the rollback processing is the same as the state of the first sub-service before the preprocessing.
In a possible implementation manner, if the second execution result is an execution failure, the second processing module is further configured to:
determining a second sub-service which is subjected to service processing in the at least one second sub-service;
and performing inverse service processing on the second sub-service subjected to the service processing.
In a possible implementation manner, the second processing module is specifically configured to:
determining an execution order of the at least one second sub-service;
and performing service processing on the at least one second sub-service according to the execution sequence until each second sub-service is successfully executed, and determining that the second execution result is successful, or determining that the second execution result is failed until any second sub-service in the at least one second sub-service is unsuccessfully executed.
In a possible implementation manner, for any one second sub-service, a state of the second sub-service after the inverse service processing is performed is the same as a state of the second sub-service before the service processing is performed.
In one possible embodiment, for any one of the first sub-services; the first processing module is specifically configured to:
acquiring a service parameter corresponding to the first sub-service in the service processing request;
judging whether the service parameters meet the service requirements corresponding to the first sub-service;
and when the service parameter is determined to meet the service requirement corresponding to the first sub-service, allocating service resources to the first sub-service, wherein the service resources are resources required for executing the processing on the first sub-service.
In a possible implementation manner, the first processing module is further configured to, if the first processing module fails to preprocess any one of the at least one first sub-service, perform fallback processing on the preprocessed 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.
In one possible embodiment, the mode of the first sub-service is an attempt-acknowledge-cancel TCC mode, and the mode of the second sub-service is a SAGA mode.
In a third aspect, an embodiment of the present application provides a multi-mode service processing device, including: a processor and a memory;
the memory stores computer-executable instructions;
the processor executes the memory-stored computer-executable instructions causing the processor to perform 8
A method of multi-mode traffic processing as claimed in any one of the first aspects.
In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored, and when the computer-executable instructions are executed by a processor, the computer-readable storage medium is configured to implement the multi-mode service processing method according to any one of the first aspect.
In a fifth aspect, the present application provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the multi-mode service processing method shown in any one of the first aspect is implemented.
According to the multi-mode service processing method, device and equipment provided by the embodiment of the application, if the distributed service comprises the sub-service in the TCC mode and the sub-service in the SAGA mode, the sub-service in the TCC mode can be preprocessed, and then the sub-service in the SAGA mode is processed after the sub-service in the TCC mode is successfully preprocessed. If the execution result of the sub-service in the SAGA mode is successful, the sub-service in the TCC mode is executed, and the sub-service in the TCC mode is preprocessed, so that the execution of the sub-service in the TCC mode is always successful, and the consistency of service processing is further ensured. And if the execution result of the sub-service in the SAGA mode is execution failure, performing rollback processing on the sub-service in the TCC mode to roll back the sub-service in the TCC mode to the initial state, so that the execution service of the sub-service in the TCC mode is also execution failure, and the consistency of service processing is further ensured.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
Fig. 1 is an architecture diagram of a distributed service system provided in an embodiment of the present application;
fig. 2 is a schematic flowchart of a multi-mode service processing method according to an embodiment of the present application;
fig. 3 is a schematic flowchart of a multi-mode service processing method according to an embodiment of the present application;
fig. 4 is an architecture diagram of a distributed service provided by an embodiment of the present application;
FIG. 5 is a schematic diagram of a process provided in an embodiment of the present application;
FIG. 6 is a schematic diagram of a process provided in an embodiment of the present application;
fig. 7 is a schematic structural diagram of a multi-mode service processing apparatus according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of a multi-mode service processing device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The terms "first," "second," "third," "fourth," and the like in the description and in the claims, as well as in the drawings, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are, for example, capable of operation in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
For ease of understanding, the concepts related to the embodiments of the present application will be first described in detail.
TCC mode: the TCC mode includes three processes, which are a preprocessing, an execution process, and a rollback process. The preprocessing refers to a try operation (try operation), the execution processing refers to a Confirm operation (Confirm operation), and the rollback processing refers to a Cancel operation (Cancel operation). Next, three kinds of processing in the TCC mode will be described.
Pretreatment: the pre-processing may typically include an inspection process and an allocation process of traffic resources. The checking process is configured to check whether the service request satisfies the service requirement corresponding to the sub-service system, for example, assuming that the service request requests to deduct an amount of 1 from an account 1, the checking process may include: and judging whether the account 1 exists or not, judging whether the password of the account 1 input by the user is correct or not, and judging whether the current balance in the account 1 is larger than the amount 1 or not. The service resource allocation process is used for allocating resources required for executing the process to the sub-service system, so as to ensure that the execution process is successful. For example, assuming that the service request requests to deduct an amount of 1 in account 1, the allocation process of the service resource may include: the amount 1 is frozen in account 1 to ensure that the amount 1 can be successfully deducted from account 1 in subsequent executions.
Executing the processing: the execution process is used to complete the business logic process. For example, assuming that the service request requests a deduction of amount 1 in account 1, the execution process may realize the deduction of amount 1 in account 1. In the TCC mode, if the preprocessing is successful, the execution process must be successful.
And (3) rollback processing: when the preprocessing or the execution processing fails, the method and the device perform rollback operation on the executed processing to cancel the performed operation and release the service resources allocated in the preprocessing stage.
SAGA mode: the SAGA mode is a distributed transaction implementation mode based on compensation transaction, and under the SAGA mode, the distributed service comprises a plurality of sub-services, wherein each sub-service corresponds to service processing and inverse service processing, the service processing can also be forward service processing, and the inverse service processing can also be reverse compensation processing. And when the distributed service in the SAGA mode is executed, forward service processing is sequentially executed on each sub-service, and if the forward service processing of all the sub-services is successfully executed, the distributed service execution is completed. If the forward service processing of any sub-service fails, the sub-service which has already undergone the forward service processing is subjected to reverse service processing (reverse compensation processing) so as to return the sub-service which has already undergone the forward service processing to the initial state.
Service consistency of distributed services: the distributed services comprise a plurality of sub-services, and the service consistency means that the processing results of each sub-service are the same, and the processing results of the plurality of sub-services are either all successful in execution or all failed in execution.
A distributed service system according to an embodiment of the present application will be described below with reference to fig. 1.
Fig. 1 is an architecture diagram of a distributed service system according to an embodiment of the present application. Referring to fig. 1, the distributed service system includes a service manager and a plurality of sub-service systems. The distributed service comprises a plurality of sub-services, and one sub-service system can be used for processing one sub-service. The service manager is used for calling and managing the sub-service systems so as to ensure that the processing results of the sub-service systems to the respective corresponding sub-services are consistent. One sub-service system may be deployed in one virtual machine, and different virtual machines may be deployed on the same physical device or may be deployed on different physical devices. The service manager may be deployed on the same physical device as the sub-service system, or the service manager may be deployed on a different physical device from the sub-service system.
Optionally, if the sub-service system is in the TCC mode, the sub-service system may include three interfaces: an interface for performing preprocessing, an interface for performing execution processing, and an interface for performing rollback processing. Accordingly, the service manager may invoke an interface of the sub-service system to cause the sub-service system to perform pre-processing, execution processing, or fallback processing.
Optionally, if the sub-service system is in the SAGA mode, the sub-service system may include two interfaces: an interface for performing service processing and an interface for performing inverse service processing. Accordingly, the service manager may call an interface of the sub-service system to enable the sub-service system to perform service processing or inverse service processing.
In the related art, if the modes of the sub-service systems in the service system are different, that is, the modes of the sub-services included in the distributed service are different, it is not possible to ensure that the processing results of the sub-services in the distributed service are consistent, that is, it is not possible to ensure the service consistency of the distributed service, which results in poor reliability of service processing.
In order to solve the above technical problem, in the embodiment of the present disclosure, if the distributed service includes a TCC mode sub-service and an SAGA mode sub-service, the TCC mode sub-service may be preprocessed, and then the SAGA mode sub-service may be processed. If the execution result of the sub-service in the SAGA mode is successful, the sub-service in the TCC mode is executed, and the sub-service in the TCC mode is preprocessed, so that the execution of the sub-service in the TCC mode is always successful, and the consistency of service processing is further ensured. And if the execution result of the sub-service in the SAGA mode is execution failure, performing rollback processing on the sub-service in the TCC mode to roll back the sub-service in the TCC mode to the initial state, so that the execution service of the sub-service in the TCC mode is also execution failure, and the consistency of service processing is further ensured.
The technical means shown in the present application will be described in detail below with reference to specific examples. The following embodiments may exist independently or may be combined with each other, and the description of the same or similar contents will not be repeated in different embodiments.
Fig. 2 is a schematic flowchart of a multi-mode service processing method according to an embodiment of the present application. Referring to fig. 2, the method may include:
s201, acquiring a service processing request.
An execution main body in the embodiment of the present application may be a distributed service system, a part of steps in the embodiment of the present application may be executed by a service manager in the distributed service system, and a part of steps may be executed by the service manager invoking a sub-service system.
Optionally, the service manager in the distributed service system may obtain the service processing request.
The service processing request is used for requesting to process a first service, the first service comprises at least one first sub-service and at least one second sub-service, and the modes of the first sub-service and the second sub-service are different. The mode of the first sub-service is a TCC mode, and the mode of the second sub-service is a SAGA mode.
The service processing request may be a service processing request from a client. For example, the service processing request may be a request to transfer a predetermined amount of money in account 1 to account 2, and assuming that the service processing request corresponds to a first service, the first service includes two sub-services, sub-service 1: deducting a predetermined amount of money in account 1, sub-service 2: a predetermined amount of money is credited to the account 2.
S202, preprocessing each first sub-service respectively.
Optionally, after the service manager obtains the service processing request, the service manager may respectively call the corresponding sub-service systems, so that the sub-service systems process the corresponding first sub-services.
The preprocessing is used to make the result of the execution processing on the first sub-service be successful, that is, if the preprocessing on the first sub-service is successful, the execution processing on the first sub-service is also certain successful.
The preprocessing may include a checking process and a service resource allocation process, where the checking process is used to detect whether the service parameter in the service processing request satisfies a service requirement corresponding to the first sub-service. The allocation process of the service resources is used for dividing the service resources required for executing the process on the first sub-service. And if the first sub-service is successfully checked and processed and the first sub-service is successfully distributed, the first sub-service is successfully preprocessed. After the first sub-service is successfully preprocessed, the first sub-service already meets the requirement that the execution processing is successful, so that the execution processing of the first sub-service is certainly successful by default after the first sub-service is successfully preprocessed.
The same procedure for preprocessing each first sub-service is described below, where the procedure for preprocessing any one first sub-service is as follows: acquiring a service parameter corresponding to the first sub-service in the service processing request, judging whether the service parameter meets a service requirement corresponding to the first sub-service (checking processing), and when the service parameter is determined to meet the service requirement corresponding to the first sub-service, allocating a service resource for the first sub-service, wherein the service resource is a resource required for executing processing on the first sub-service (allocation processing of the service resource).
For example, assume that the first sub-service is: deducting a preset amount from the account 1, where the service request may include the account 1, the password of the account 1, and the preset amount, and the checking may include: checking whether account 1 exists, checking whether the password of account 1 is correct, and checking whether the amount of money in account 1 is greater than or equal to a preset amount of money. The process of allocating traffic resources may include: a preset amount is frozen in account 1.
Optionally, at least one first sub-service may be preprocessed in parallel, or at least one first sub-service may be preprocessed sequentially. For example, a processing order of at least one first sub-service may be obtained, and the at least one first sub-service is preprocessed according to the processing order.
S203, if the preprocessing of the at least one first sub-service is successful, the at least one second sub-service is processed to obtain a second execution result corresponding to the at least one second sub-service.
Whether the pre-processing of the first sub-service is successful may be determined by the service manager. After the service manager determines to preprocess at least one first sub-service, 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.
And if the preprocessing of each first sub-service is successful, performing service processing on at least one second sub-service.
The service processing may be performed on the at least one second sub-service in the following manner, so as to obtain a second execution result corresponding to the at least one second sub-service: and determining an execution sequence of the at least one second sub-service, and performing service processing on the at least one second sub-service according to the execution sequence until each second sub-service is successfully executed, determining that a second execution result is successful in execution, or determining that a second execution result is failed in execution until any second sub-service in the at least one second sub-service is failed in execution.
For example, assume that the at least one second sub-service includes sub-service 1, sub-service 2, sub-service 3, and sub-service 4, and the execution order of the 4 sub-services is: the sub-service 1, the sub-service 2, the sub-service 3, and the sub-service 4 may sequentially perform service processing on the 4 sub-services. Assuming that the service processing is successfully performed on all the 4 sub-services, the second execution result corresponding to the 4 sub-services is successful. If the sub-service 1 and the sub-service 2 are successfully processed and the sub-service 3 is failed to be processed, the sub-service 4 is not continuously processed, and the second execution result is determined to be failed to be executed. After determining that the execution of the second execution result fails, the sub-service 1 and the sub-service 2 may be subjected to inverse service processing, so that the sub-service 1 and the sub-service 2 are backed to an initial state (a state before performing service processing), and if the sub-service 3 is also subjected to partial service processing, the partial service processing already performed in the service 3 is also subjected to the back processing.
For any one 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.
And S204, respectively performing execution processing or backspacing processing on each first sub-service according to the second execution result to obtain a first execution result corresponding to each first sub-service.
Wherein the first execution result is the same as the second execution result. The first execution result and the second execution result are both successfully executed, or the first execution result and the second execution result are both failed to execute.
And if the second execution result is successful, executing each first sub-service respectively to obtain a first execution result corresponding to each first sub-service, wherein the first execution result corresponding to each first sub-service is successful in execution. In this case, both the first execution result and the second execution result are successfully executed.
And if the second execution result is execution failure, performing rollback processing on each first sub-service respectively to obtain a first execution result corresponding to each first sub-service, wherein 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.
The fallback processing can be performed on the first sub-service in the following manner: and performing rollback processing on the preprocessing 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 the rollback processing is the same as the state of the first sub-service before the preprocessing.
In the embodiment shown in fig. 2, if the distributed service includes a TCC mode sub-service and an SAGA mode sub-service, the TCC mode sub-service may be preprocessed, and then the SAGA mode sub-service may be processed. If the execution result of the sub-service in the SAGA mode is successful, the sub-service in the TCC mode is executed, and the sub-service in the TCC mode is preprocessed, so that the execution of the sub-service in the TCC mode is always successful, and the consistency of service processing is further ensured. And if the execution result of the sub-service in the SAGA mode is execution failure, performing rollback processing on the sub-service in the TCC mode to roll back the sub-service in the TCC mode to the initial state, so that the execution service of the sub-service in the TCC mode is also execution failure, and the consistency of service processing is further ensured.
Based on any of the above embodiments, the following describes the procedure of the multi-mode service processing in detail with reference to the embodiment shown in fig. 3.
Fig. 3 is a flowchart illustrating a multi-mode service processing method according to an embodiment of the present application. Referring to fig. 3, the method may include:
s301, acquiring a service processing request.
S302, preprocessing each first sub-service respectively.
It should be noted that the execution processes of S301 to S302 may refer to the execution processes of S201 to S202, and are not described herein again.
S303, judging whether each first sub-service is preprocessed successfully or not.
If yes, S305 is performed.
If not, go to step S304.
S304, performing rollback processing on the preprocessed first sub-service.
And after the first sub-service which is preprocessed is subjected to rollback processing, service processing is not continued to be performed on the second sub-service, and in this case, the execution result of the first sub-service and the execution result of the second sub-service are both failed to be executed.
S305, 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.
S306, judging whether the second execution result corresponding to the at least one second sub-service is successful.
If yes, go to step S307.
If not, go to S308.
And if the execution of each second sub-service in the at least one second sub-service is successful, determining that the second execution result is successful. And if the execution of any one second sub-service in the at least one second sub-service fails, determining that the second execution result is the execution failure.
It should be noted that the execution process of S306 may refer to the execution process of S203, and is not described herein again.
S307, executing each first sub-service respectively to obtain a first execution result corresponding to each first sub-service.
And if the execution of each second sub-service is successful, executing each first sub-service, wherein the first execution result of executing the first sub-service is successful because the first sub-service is preprocessed. Namely, the execution results of the first sub-service and the second sub-service are both successfully executed, so that the consistency of the execution results of the first sub-service and the second sub-service is ensured.
S308, determining the second sub-service which is processed by the service in at least one second sub-service.
The second sub-service subjected to service processing comprises: the second sub-service which has completed the service processing and whose execution result is successful, and the second sub-service which has completed part of the service processing and whose execution result is failed.
S309, performing inverse business processing on the second sub-business which is subjected to the business processing.
The anti-service processing refers to revoking processing that has been performed by the second sub-service. The second sub-service is subjected to inverse service processing, so that the state of the second sub-service can be returned to an initial state, and the initial state is a state before service processing.
For example, assume that the service processing performed by the second sub-service is: and when a preset amount is deposited in the account 1, performing anti-service processing on the second sub-service as follows: a predetermined amount is deducted from account 1.
S310, performing rollback processing on each first sub-service respectively to obtain a first execution result corresponding to each first sub-service.
And if the second sub-service is failed to be processed, performing rollback processing on each first sub-service respectively so as to enable the state of each first sub-service to be rolled back to the initial state. Since only the first sub-service is preprocessed, the rollback processing of the first sub-service refers to performing rollback processing on the preprocessing of the first sub-service, that is, undoing the preprocessing of the first sub-service.
For example, the preprocessing performed on the first sub-service includes: and if the preset amount in the account 1 is frozen, the returning processing of the first sub-service means canceling the preset amount in the account 1.
And when the second sub-service is failed to be processed, the first sub-service is also subjected to rollback processing, so that the execution of the first execution result service corresponding to the first sub-service fails. That is, the execution result of the first sub-service and the execution result of the second sub-service are both failed to be executed, so that the consistency of the execution results of the first sub-service and the second sub-service is ensured.
In the embodiment shown in fig. 3, if the distributed service includes a TCC mode sub-service and an SAGA mode sub-service, the TCC mode sub-service may be preprocessed, and then the SAGA mode sub-service may be processed. If the execution result of the sub-service in the SAGA mode is successful, the sub-service in the TCC mode is executed, and the sub-service in the TCC mode is preprocessed, so that the execution of the sub-service in the TCC mode is always successful, and the consistency of service processing is further ensured. And if the execution result of the sub-service in the SAGA mode is execution failure, performing rollback processing on the sub-service in the TCC mode to roll back the sub-service in the TCC mode to the initial state, so that the execution service of the sub-service in the TCC mode is also execution failure, and the consistency of service processing is further ensured.
On the basis of any of the above embodiments, the following describes the multi-mode service processing method by using specific examples in conjunction with fig. 4 to fig. 6.
Fig. 4 is an architecture diagram of a distributed service provided in an embodiment of the present application. Referring to fig. 4, if the distributed service is assumed that the user purchases a financial product on the third-party platform through the account 1, the distributed service includes 5 sub-services, where the 5 sub-services are: deducting a predetermined amount of money from account 1 (sub-service 1), crediting the predetermined amount of money to a third party account (sub-service 2), performing a transaction process (sub-service 3), deducting the predetermined amount of money from the third party account (sub-service 4), crediting the predetermined amount of money to account 2 (sub-service 5). The sub-service 1, the sub-service 2 and the sub-service 3 are in a TCC mode, and the sub-service 4 and the sub-service 5 are in an SAGA mode.
The processing procedure of the distributed service shown in fig. 4 will be described with reference to fig. 5 to 6.
Fig. 5 is a schematic diagram of a processing procedure provided in an embodiment of the present application. Referring to fig. 5, when processing the distributed service, the sub-service 1, the sub-service 2, and the sub-service 3 are preprocessed, respectively. And if the sub-service 1, the sub-service 2 and the sub-service 3 are all preprocessed successfully, performing service processing on the sub-service 4 and the sub-service 5. If the sub-service 4 and the sub-service 5 are successfully processed, that is, the corresponding execution results of the sub-service 4 and the sub-service 5 are successfully executed, the sub-service 1, the sub-service 2, and the sub-service 3 are respectively executed, and since the sub-service 1 to the sub-service 3 are preprocessed, the execution results of the sub-service 1 to the sub-service 3 are definitely successful. Namely, the execution results of the sub-service 1 to the sub-service 5 are all successful, and the consistency of service execution is ensured.
Fig. 6 is a schematic diagram of a processing procedure provided in an embodiment of the present application. Referring to fig. 6, when processing the distributed service, the sub-service 1, the sub-service 2, and the sub-service 3 are preprocessed, respectively. And if the sub-service 1, the sub-service 2 and the sub-service 3 are all preprocessed successfully, performing service processing on the sub-service 4 and the sub-service 5. If the sub-service 4 is successfully processed and the sub-service 5 is failed to be processed, the sub-service 4 is continuously processed in a reverse mode, so that the execution results of the sub-service 4 and the sub-service 5 are both failed to be executed. And after the sub-service 4 and the sub-service 5 are failed to be executed, respectively carrying out backspacing processing on the sub-services 1 to 3 so as to enable the execution results of the sub-services 1 to 3 to be failed to be executed. Namely, the execution results of the sub-service 1 to the sub-service 5 are all successful, and the consistency of service execution is ensured.
Fig. 7 is a schematic structural diagram of a multi-mode service processing apparatus according to an embodiment of the present application. Referring to fig. 7, the multi-mode service processing apparatus 10 may include: an acquisition module 11, a first processing module 12 and a second processing module 13, wherein,
the obtaining module 11 is configured to 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, and modes of the first sub-service and the second sub-service are different;
the first processing module 12 is configured to respectively perform preprocessing on each first sub-service, where the preprocessing is used to make a result of performing processing on the first sub-service successful;
the second processing module 13 is configured to, if the first processing module successfully preprocesses 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 12 is further configured 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, where the first execution result is the same as the second execution result.
The multi-mode service processing apparatus provided in the embodiment of the present application may execute the technical solutions shown in the foregoing method embodiments, and the implementation principles and beneficial effects thereof are similar and will not be described herein again.
In a possible implementation, the first processing module 12 is specifically configured to:
if the second execution result is successful, performing execution processing on each first sub-service respectively to obtain a first execution result corresponding to each first sub-service, wherein the first execution result corresponding to each first sub-service is successful;
and if the second execution result is execution failure, performing rollback processing on each first sub-service respectively to obtain a first execution result corresponding to each first sub-service, wherein the first execution result corresponding to each first sub-service is execution failure.
In one possible embodiment, for any one of the first sub-services; the first processing module 12 is specifically configured to:
and performing rollback processing on the preprocessing 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 the rollback processing is the same as the state of the first sub-service before the preprocessing.
In a possible implementation manner, if the second execution result is an execution failure, the second processing module 12 is further configured to:
determining a second sub-service which is subjected to service processing in the at least one second sub-service;
and performing inverse service processing on the second sub-service subjected to the service processing.
In a possible implementation manner, the second processing module 12 is specifically configured to:
determining an execution order of the at least one second sub-service;
and performing service processing on the at least one second sub-service according to the execution sequence until each second sub-service is successfully executed, and determining that the second execution result is successful, or determining that the second execution result is failed until any second sub-service in the at least one second sub-service is unsuccessfully executed.
In a possible implementation manner, for any one second sub-service, a state of the second sub-service after the inverse service processing is performed is the same as a state of the second sub-service before the service processing is performed.
In one possible embodiment, for any one of the first sub-services; the first processing module 12 is specifically configured to:
acquiring a service parameter corresponding to the first sub-service in the service processing request;
judging whether the service parameters meet the service requirements corresponding to the first sub-service;
and when the service parameter is determined to meet the service requirement corresponding to the first sub-service, allocating service resources to the first sub-service, wherein the service resources are resources required for executing the processing on the first sub-service.
In a possible implementation manner, the first processing module 12 is further configured to, if the first processing module 12 fails to preprocess any one of the at least one first sub-service, perform fallback processing on the preprocessed 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.
In one possible embodiment, the mode of the first sub-service is an attempt-acknowledge-cancel TCC mode, and the mode of the second sub-service is a SAGA mode.
The multi-mode service processing apparatus provided in the embodiment of the present application may execute the technical solutions shown in the foregoing method embodiments, and the implementation principles and beneficial effects thereof are similar and will not be described herein again.
Fig. 8 is a schematic structural diagram of a multi-mode service processing device according to an embodiment of the present application. Referring to fig. 8, the multi-mode traffic processing device 20 may include a processor 21 and a memory 22. The processor 21, the memory 22, and the various parts are illustratively interconnected by a bus 23.
The memory 21 stores computer-executable instructions;
the processor 21 executes computer-executable instructions stored by the memory 22 to cause the processor 21 to perform the multi-mode traffic processing method according to any of the first aspects.
The multi-mode service processing device shown in the embodiment of fig. 8 may execute the technical solution shown in the above method embodiment, and the implementation principle and the beneficial effect thereof are similar, and details are not described here again.
The embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored, and when the computer-executable instructions are executed by a processor, the computer-readable storage medium is used for implementing the multi-mode service processing method.
The present application may further provide a computer program product, which includes a computer program, and when the computer program is executed by a processor, the multi-mode service processing method may be implemented.
All or a portion of the steps of implementing the above-described method embodiments may be performed by hardware associated with program instructions. The aforementioned program may be stored in a readable memory. When executed, the program performs steps comprising the method embodiments described above; and the aforementioned memory (storage medium) includes: read-only memory (ROM), RAM, flash memory, hard disk, solid state disk, magnetic tape (magnetic tape), floppy disk (flexible disk), optical disk (optical disk), and any combination thereof.
Embodiments of the present application are described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processing unit of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processing unit of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
It will be apparent to those skilled in the art that various changes and modifications may be made in the embodiments of the present application without departing from the spirit and scope of the application. Thus, if such 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 encompass such modifications and variations.
In the present application, the terms "include" and variations thereof may refer to non-limiting inclusions; the term "or" and variations thereof may mean "and/or". The terms "first," "second," and the like in this application are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. In the present application, "a plurality" means two or more. "and/or" describes the association relationship of the associated objects, meaning that there may be three relationships, e.g., a and/or B, which may mean: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship.

Claims (13)

1. A method for processing multi-mode traffic, comprising:
acquiring a service processing request, wherein the service processing request is used for requesting to process a first service, the first service comprises at least one first sub-service and at least one second sub-service, and the modes of the first sub-service and the second sub-service are different;
respectively preprocessing each first sub-service, wherein the preprocessing is used for enabling the execution processing result of the first sub-service to be successful;
if the at least one first sub-service is successfully preprocessed, 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;
and respectively performing execution processing or backspacing processing on each first sub-service according to the second execution result to obtain a first execution result corresponding to each first sub-service, wherein the first execution result is the same as the second execution result.
2. The method of claim 1, wherein performing execution processing or rollback processing on each first sub-service according to the second execution result to obtain a first execution result corresponding to each first sub-service comprises:
if the second execution result is successful, performing execution processing on each first sub-service respectively to obtain a first execution result corresponding to each first sub-service, wherein the first execution result corresponding to each first sub-service is successful;
and if the second execution result is execution failure, performing rollback processing on each first sub-service respectively to obtain a first execution result corresponding to each first sub-service, wherein the first execution result corresponding to each first sub-service is execution failure.
3. The method of claim 2, wherein for any one of the first sub-services; performing fallback processing on the first sub-service to obtain a first execution result corresponding to the first sub-service, including:
and performing rollback processing on the preprocessing 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 the rollback processing is the same as the state of the first sub-service before the preprocessing.
4. The method of claim 2 or 3, wherein if the second execution result is an execution failure, the method further comprises:
determining a second sub-service which is subjected to service processing in the at least one second sub-service;
and performing inverse service processing on the second sub-service subjected to the service processing.
5. The method according to claim 4, wherein 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;
and performing service processing on the at least one second sub-service according to the execution sequence until each second sub-service is successfully executed, and determining that the second execution result is successful, or determining that the second execution result is failed until any second sub-service in the at least one second sub-service is unsuccessfully executed.
6. The method according to claim 5, wherein for any second sub-service, a state of the second sub-service after the anti-service processing is performed is the same as a state of the second sub-service before the service processing is performed.
7. The method according to any of claims 1-6, characterized in that for any one first sub-service; preprocessing the first sub-service, including:
acquiring a service parameter corresponding to the first sub-service in the service processing request;
judging whether the service parameters meet the service requirements corresponding to the first sub-service;
and when the service parameter is determined to meet the service requirement corresponding to the first sub-service, allocating service resources to the first sub-service, wherein the service resources are resources required for executing the processing on the first sub-service.
8. The method according to any of claims 1-7, wherein if the preprocessing fails for any of the at least one first sub-service, the method further comprises:
performing rollback processing on the preprocessed 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.
9. The method according to any of claims 1-8, wherein the mode of the first sub-service is an try-ack-cancel TCC mode, and the mode of the second sub-service is a SAGA mode.
10. A multi-mode traffic processing apparatus, comprising: an acquisition module, a first processing module and a second processing module, wherein,
the acquiring module is configured 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;
the first processing module is used for respectively preprocessing each first sub-service, and the preprocessing is used for enabling the result of executing the first sub-services to be successful;
the second processing module is configured to, if the first processing module successfully preprocesses 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 configured 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, where the first execution result is the same as the second execution result.
11. A multi-mode traffic processing device, comprising: a processor and a memory;
the memory stores computer-executable instructions;
the processor executes computer-executable instructions stored by the memory to cause the processor to perform the multi-mode traffic processing method of any of claims 1 to 9.
12. A computer-readable storage medium having computer-executable instructions stored thereon, which when executed by a processor, implement the multi-mode traffic processing method of any one of claims 1 to 9.
13. A computer program product comprising a computer program which, when executed by a processor, implements a multi-mode traffic handling method as claimed in any one of claims 1 to 9.
CN202110538092.9A 2021-05-18 2021-05-18 Multi-mode service processing method, device and equipment Pending CN113065967A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110538092.9A CN113065967A (en) 2021-05-18 2021-05-18 Multi-mode service processing method, device and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110538092.9A CN113065967A (en) 2021-05-18 2021-05-18 Multi-mode service processing method, device and equipment

Publications (1)

Publication Number Publication Date
CN113065967A true CN113065967A (en) 2021-07-02

Family

ID=76568749

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110538092.9A Pending CN113065967A (en) 2021-05-18 2021-05-18 Multi-mode service processing method, device and equipment

Country Status (1)

Country Link
CN (1) CN113065967A (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050075975A1 (en) * 2003-10-02 2005-04-07 Rosner Warren M. Allocating funds for payment of transactional account statements
CN108762895A (en) * 2018-05-17 2018-11-06 阿里巴巴集团控股有限公司 Handle the method and device of distributed transaction
CN110288255A (en) * 2019-06-28 2019-09-27 深圳前海微众银行股份有限公司 A kind of logistics method and device of distributed transaction
CN110442481A (en) * 2019-07-10 2019-11-12 阿里巴巴集团控股有限公司 Method for processing business, Service Component container and electronic equipment
CN111209142A (en) * 2020-01-02 2020-05-29 中国平安财产保险股份有限公司 Cross-database transaction management method, device, equipment and storage medium
CN111340474A (en) * 2020-05-15 2020-06-26 支付宝(杭州)信息技术有限公司 Resource processing method, device and system based on distributed transaction
CN112541830A (en) * 2020-12-29 2021-03-23 中国工商银行股份有限公司 Processing method, processing device and processing system for transaction consistency
CN112669151A (en) * 2020-12-25 2021-04-16 深圳市金证科技股份有限公司 Method and equipment for processing multi-system cooperative service

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050075975A1 (en) * 2003-10-02 2005-04-07 Rosner Warren M. Allocating funds for payment of transactional account statements
CN108762895A (en) * 2018-05-17 2018-11-06 阿里巴巴集团控股有限公司 Handle the method and device of distributed transaction
CN110288255A (en) * 2019-06-28 2019-09-27 深圳前海微众银行股份有限公司 A kind of logistics method and device of distributed transaction
CN110442481A (en) * 2019-07-10 2019-11-12 阿里巴巴集团控股有限公司 Method for processing business, Service Component container and electronic equipment
CN111209142A (en) * 2020-01-02 2020-05-29 中国平安财产保险股份有限公司 Cross-database transaction management method, device, equipment and storage medium
CN111340474A (en) * 2020-05-15 2020-06-26 支付宝(杭州)信息技术有限公司 Resource processing method, device and system based on distributed transaction
CN112669151A (en) * 2020-12-25 2021-04-16 深圳市金证科技股份有限公司 Method and equipment for processing multi-system cooperative service
CN112541830A (en) * 2020-12-29 2021-03-23 中国工商银行股份有限公司 Processing method, processing device and processing system for transaction consistency

Similar Documents

Publication Publication Date Title
CN111080449B (en) Cross-chain transaction method of blockchain, management node and blockchain network
CN111045794B (en) Distributed transaction processing method, device, system, computer equipment and storage medium
CN111026367B (en) Micro-service arrangement method, device, terminal equipment and storage medium
CN107133788B (en) Refund processing method and device
CN109325744B (en) Payment processing method, payment processing device, payment processing medium and electronic equipment
CN111738709B (en) Transaction processing method and device
CN110691077A (en) Service verification method of alliance chain and alliance chain system
CN105740085A (en) Fault tolerance processing method and device
US20180063184A1 (en) Software security verification method, device, and system
CN107038025B (en) SOA architecture-based system calling method and device
CN106874020B (en) Method and device for starting plug-in
CN109685642A (en) Credit card method for processing resource, device, electronic equipment and storage medium
CN113065967A (en) Multi-mode service processing method, device and equipment
CN114691241B (en) Task execution method, device, electronic equipment and storage medium
CN109102265B (en) Data processing method and device based on block chain
CN112598520B (en) Transaction management method, device, electronic equipment and storage medium
CN112988405B (en) Automatic degradation method and device for micro-service and computing equipment
CN108710557B (en) Method and system for judging data consistency of distributed software program
CN112819479A (en) Order state processing method and device, storage medium and server
CN113900741B (en) Service processing method and device based on plug-in, computer equipment and medium
CN112882921A (en) Fault simulation method and device
CN113052687A (en) Transaction routing distribution method and related device
CN110827009B (en) Fund transfer method and device based on account balance limit
US7752254B2 (en) Propagating contexts between a first and second system
CN106302627B (en) Service change method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination