Service orchestration-oriented bidirectional compensation transaction consistency processing method and system
By introducing a two-way compensation transaction consistency processing method in service orchestration, the data consistency problem in service orchestration is solved, and efficient resource management and system fault tolerance are achieved.
Patent Information
- Application Number
- CN202510141178.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-08
- Publication Date
- 2025-06-13
AI Technical Summary
Under the microservice architecture, service orchestration fails due to network environment fluctuations and service stability issues, resulting in inconsistent execution status between services, destroying data integrity and business process continuity.
The two-way compensation transaction consistency processing method for service-oriented orchestration is adopted. By generating global transactions and branch transactions, the business process is gradually executed, and the transaction compensation mechanism is triggered when node exceptions are triggered, and the reverse or forward compensation strategy is implemented to ensure data consistency.
It effectively solves the data consistency problem in service orchestration, reduces resource locking time and system waiting overhead, and improves the system's fault tolerance and flexibility and efficiency of transaction consistency processing.
Smart Images

Figure CN120144235A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technologies, and in particular, to a method and system for processing two-way compensation transaction consistency for service orchestration. Background Art
[0002] Under the microservices architecture, a huge monolithic application is finely deconstructed into a series of microservice units that can be independently developed, tested, deployed, and extended. This transformation has greatly promoted the flexibility and maintainability of the system. Service orchestration technology, with its intuitive drag-and-drop interface and flexible parameter configuration mechanism, realizes the efficient combination and orchestration of microservices, making the expansion and iteration of business functions rapid and convenient.
[0003] However, since the microservices participating in the orchestration may span multiple different business systems and technical fields, and they interact and call frequently through the network, while this mode improves the flexibility of the system, it also introduces new challenges. Fluctuations in the network environment, stability issues of the services themselves, or anomalies in any microservice node may cause a failure in the execution of a certain link in the service chain, thereby resulting in inconsistent execution states among services. This inconsistency not only destroys the integrity and accuracy of data but may also seriously affect the continuity and reliability of business processes, especially in industries with extremely high requirements for data consistency such as finance and e-commerce. Therefore, in the practice of service orchestration, ensuring the data consistency of the orchestrated services has become a crucial and urgent core issue in this field.
[0004] Patent document CN116931945A discloses a service orchestration processing method, device, electronic device, and storage medium, including: during the execution of service orchestration, in response to determining that the currently executed node is an abnormal node, executing a custom first exception handling method; in response to determining that the to-be-executed second exception handling method is a predetermined exception handling method, and the abnormal node is within any transaction included in the service orchestration, taking the transaction as the target transaction, completing the rollback operation for the target transaction, and executing the second exception handling method.
[0005] However, although patent document CN116931945A differentiates between local services and remote services and attempts to manage the execution state by creating local transactions and distributed transactions, it only uses a relatively single rollback operation when the service execution fails, lacks a flexible compensation mechanism and a complete exception handling strategy, has fewer applicable scenarios, and the mechanism is not complete enough; at the same time, this patent document does not fully consider the full life cycle management of transactions, idempotency requirements, and detailed logging, which will lead to consistency and reliability problems when dealing with complex transaction processes.
[0006] Patent document CN118796361A discloses a strongly consistent distributed transaction processing system and method for service orchestration, including the following steps: S1. The service orchestration end initiates a global transaction; S2. The service orchestration end connects to the service orchestration transaction cluster for registration and storage of the global transaction, obtains the unique global transaction identifier XID, and records the transaction log; S3. The service orchestration end calls the atomic service interface and implicitly passes the unique global transaction identifier XID; S4. The business application end connects to the business transaction cluster through the atomic service interface for registration and storage of the branch transaction. If the registration and storage of the branch transaction fail, steps S5 and S6 are executed. If the registration and storage of the branch transaction succeed, the process ends; S5. The service orchestration end sends a global transaction commit or rollback instruction to the service orchestration transaction cluster, or the service orchestration transaction cluster triggers a global transaction commit or rollback; S6. The service orchestration end calls the atomic service interface to commit or roll back the branch transaction. If the commit or rollback operation of the branch transaction fails, it is retried the maximum number of times. If it still fails after the maximum number of retries, it is transferred to manual intervention for processing.
[0007] However, patent document CN118796361A realizes the transaction consistency of each node in service orchestration through branch transaction rollback. This method requires that the branch transactions of each node must be committed after the global transaction is committed, resulting in a long waiting time for each node service, causing a large number of resources to be locked, increasing the system burden. In addition, if service orchestration involves multiple services and the execution time is long, the time for locking resources will also be extended, significantly increasing the deadlock risk and further affecting the system performance and stability. Summary of the Invention
[0008] Aiming at the defects in the prior art, the purpose of the present invention is to provide a two-way compensation transaction consistency processing method and system for service orchestration.
[0009] According to a two-way compensation transaction consistency processing method for service orchestration provided by the present invention, it includes:
[0010] Step S1: The service orchestration control plane generates a business process and pushes it to the configuration center;
[0011] Step S2: The service orchestration data plane reads the process configuration corresponding to the business process from the configuration center, starts a global transaction for the current business process, and registers an empty branch transaction list in the global cache of the service orchestration data plane;
[0012] Step S3: The service orchestration data plane gradually executes each request node in the current business process;
[0013] Step S4: Before each request node starts to execute, the service orchestration data plane assembles the initial branch transaction information using the unique identifier of the current request node as the corresponding branch transaction identifier;
[0014] Step S5: After each request node finishes execution, the service orchestration data plane updates the corresponding branch transaction information of the current request node;
[0015] Step S6: Store the updated branch transaction information of the current request node in the branch transaction information list corresponding to the business process in the global cache in sequence, and determine whether the node has executed abnormally. If so, trigger the transaction compensation mechanism and execute the corresponding compensation strategy according to the process configuration of the current business process; if not, execute Step S7;
[0016] Step S7: Determine whether the current business process has been executed completely. If so, the service orchestration data plane assembles the final result into the response body and returns it to the client; if not, return to Step S4.
[0017] Preferably, the service orchestration control plane is responsible for centralized operations including resource management, process drawing, process debugging, and process backtracking in a visual manner;
[0018] The service orchestration data plane is responsible for providing a running environment for the published business processes in service orchestration. At the same time, as the transaction manager of distributed transactions during the running process, the data plane undertakes the responsibilities of registration, coordination, and destruction of distributed transactions.
[0019] Preferably, the global cache is used to store all branch transaction information of the current business process;
[0020] Step S2 includes generating a global transaction unique identifier and registering it in the global cache of the service orchestration data plane with the unique identifier as the key and an empty array as the value;
[0021] The branch transaction information is a hash structure, including the branch transaction identifier corresponding to the current request node, the execution start time, and the node execution status;
[0022] Updating the corresponding branch transaction information includes adding the execution end time and updating the node execution status.
[0023] Preferably, the transaction compensation mechanism includes a reverse compensation mode and a forward compensation mode;
[0024] The reverse compensation mode ensures the consistency of service execution status under orchestration by invoking the compensation service when the business service execution fails. Each request node is configured with a corresponding compensation service. After the business service execution fails, the compensation service restores the data to the state before the service execution, and the compensation service meets the idempotency requirement;
[0025] The forward compensation mode ensures the consistency of service execution status under orchestration by continuously retrying the abnormal business service when the business service execution fails.
[0026] Preferably, the forward compensation strategy corresponding to the forward compensation mode includes:
[0027] Step S601: The service orchestration data plane continuously performs backoff retries according to the retry configuration configured for the current request node, and determines whether the execution of the current abnormal node is successful. If so, continue to execute the remaining process and return the final processing result to the client; if not, execute Step S602;
[0028] Step S602: Determine whether the number of retries has reached the retry threshold configured in the current request node. If so, record the information of the business service with execution failure and the response result of the business service in the branch transaction information; if not, return to Step S601;
[0029] Step S603: Compose the information including process execution failure, abnormal business service, and abnormal response result into a complete response body and return it to the client.
[0030] Preferably, the reverse compensation strategy corresponding to the reverse compensation mode includes:
[0031] Step S611: The service orchestration data plane finds the list of branch transaction information corresponding to the current business process from the global cache and traverses the list of branch transaction information in reverse;
[0032] Step S612: Query the compensation service of the corresponding request node according to the branch transaction identifier in each branch transaction information. If no compensation service is queried, it means that the request node does not require a compensation service when an exception occurs, and return to Step S611; if a compensation service is queried, execute the compensation service and record the execution result and the number of retries in the corresponding branch transaction information;
[0033] Step S613: Determine whether the execution of the compensation service is successful. If so, execute Step S614; if not, execute Step S615;
[0034] Step S614: Determine whether all compensation services have been executed. If so, return the information of process execution failure and successful transaction rollback to the client; if not, return to Step S612;
[0035] Step S615: Determine whether the number of retry attempts has reached the retry threshold configured in the current request node. If so, record the compensation service information and the response result of the compensation service for the failed rollback action in the branch transaction information, and then form a complete response body by combining the compensation service information for the failed process execution, failed transaction rollback, and failed rollback execution and the return response result of the compensation service, and return it to the client; if not, return to step S612.
[0036] Preferably, after returning the response body to the client, the service orchestration data plane combines the list of branch transaction information corresponding to the business process in the global cache, records the execution log in the local log file of the data plane for subsequent process backtracking, and then deletes the list of branch transaction information corresponding to the process in the global cache to complete transaction destruction.
[0037] A two-way compensation transaction consistency processing system for service orchestration provided by the present invention includes: a service orchestration control plane, a configuration center, and a service orchestration data plane;
[0038] The service orchestration control plane generates a business process and pushes it to the configuration center;
[0039] The service orchestration data plane reads the process configuration of the corresponding business process from the configuration center, starts a global transaction for the current business process, and registers an empty branch transaction list in the global cache of the service orchestration data plane;
[0040] The service orchestration data plane gradually executes each request node in the current business process; before each request node starts to execute, the service orchestration data plane assembles the initial branch transaction information using the uniqueness identifier of the current request node as the corresponding branch transaction identifier; after each request node finishes executing, the service orchestration data plane updates the corresponding branch transaction information of the current request node.
[0041] The updated branch transaction information of the current request node is sequentially stored in the list of branch transaction information corresponding to the business process in the global cache, and it is determined whether the node has executed abnormally. If so, trigger the transaction compensation mechanism and execute the corresponding compensation strategy according to the process configuration of the current business process; if not, return the final processing result to the client after all nodes are executed.
[0042] Preferably, the global cache is used to store all branch transaction information of the current business process;
[0043] The start of the global transaction includes generating a global transaction uniqueness identifier and registering it in the global cache of the service orchestration data plane with the uniqueness identifier as the key and an empty array as the value;
[0044] The branch transaction information is in a hash structure, including the branch transaction identifier corresponding to the current request node, the execution start time, and the node execution status;
[0045] The update of the corresponding branch transaction information includes adding the execution end time and updating the node execution status.
[0046] Preferably, the transaction compensation mechanism includes a reverse compensation mode and a forward compensation mode;
[0047] The reverse compensation mode ensures the consistency of the service execution status under the orchestration by calling the compensation service when the business service execution fails. Each request node is configured with a corresponding compensation service. After the business service execution fails, the compensation service restores the data to the state before the service execution, and the compensation service meets the idempotency requirement;
[0048] The forward compensation mode ensures the consistency of the service execution status under the orchestration by continuously retrying the abnormal business service when the business service execution fails.
[0049] Compared with the prior art, the present invention has the following beneficial effects:
[0050] 1. By introducing a distributed transaction based on a two-way compensation mechanism, this patent solves the data consistency problem in the service orchestration scenario, effectively promoting the in-depth application and development of service orchestration technology in industries with extremely high requirements for data consistency, such as finance and e-commerce.
[0051] 2. The "non-intrusive" integration method of the present invention greatly reduces the difficulty and cost of technology implementation, enabling existing systems to quickly and simply perform business integration through service orchestration, thereby enjoying the flexibility and scalability advantages brought by service orchestration.
[0052] 3. The present invention allows the branch transactions of each node to be committed immediately after being locally executed, without waiting for all nodes to complete, thus significantly reducing the resource locking time and system waiting overhead. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] By reading the detailed description of the non-restrictive embodiments with reference to the following drawings, other features, objectives, and advantages of the present invention will become more apparent:
[0054] Figure 1 It is a schematic flowchart of the working method of the present invention;
[0055] Figure 2 It is a schematic flowchart of the transaction compensation mechanism in the present invention. DETAILED DESCRIPTION OF THE INVENTION
[0056] The present invention will be described in detail below in conjunction with specific embodiments. The following embodiments will help those skilled in the art to further understand the present invention, but do not limit the present invention in any form. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present invention, several changes and improvements can still be made. These all belong to the protection scope of the present invention.
[0057] The present invention provides a two-way compensation transaction consistency processing method for service orchestration to solve the problem of inconsistent service execution states under different request nodes caused by the failure of a certain request node in the orchestration, ensuring that the data processing of all services is either all successful or all not executed, and guaranteeing data consistency among all orchestrated services. This solution introduces a flexible transaction processing mechanism and a convenient orchestration configuration mode in the orchestration scenario to ensure data consistency of the service nodes participating in the orchestration without affecting the usability and availability of the service orchestration itself.
[0058] Embodiment 1
[0059] According to a two-way compensation transaction consistency processing method for service orchestration provided by the present invention, as Figure 1 and Figure 2 shown, it includes:
[0060] Step S1: The service orchestration control plane generates a business process and pushes it to the configuration center. The service orchestration control plane is responsible for centralized resource management, process drawing, process debugging, process backtracking, etc. in a visual manner.
[0061] Step S2: The service orchestration data plane reads the process configuration corresponding to the business process from the configuration center, starts a global transaction for the current business process, and registers an empty branch transaction list in the global cache of the service orchestration data plane. The global cache is used to store all branch transaction information of the current business process. Step S2 includes generating a unique identifier for the global transaction and registering it in the global cache of the service orchestration data plane with the unique identifier as the key and an empty array as the value. The service orchestration data plane is the place where the real running process is located, responsible for providing a running environment for the business processes (hereinafter referred to as processes) published in the service orchestration. At the same time, as the transaction manager of the distributed transaction when running the process, the data plane undertakes the responsibilities of registering, coordinating, and destroying the distributed transaction.
[0062] Step S3: The service orchestration data plane gradually executes each request node in the current business process.
[0063] Step S4: Before each request node starts to execute, the service orchestration data plane assembles the initial branch transaction information using the unique identifier of the current request node as the corresponding branch transaction identifier. Specifically, the branch transaction information in the form of a hash structure is composed of information such as the branch transaction identifier corresponding to the current request node, the start time of execution, and the node execution status.
[0064] Step S5: After each request node finishes execution, the service orchestration data plane updates the corresponding branch transaction information of the current request node. The operation of updating the corresponding branch transaction information includes adding the end time of execution, updating the node execution status, etc.
[0065] Step S6: The updated branch transaction information of the current request node is sequentially stored in the branch transaction information list corresponding to the business process in the global cache, and it is judged whether the node has an execution exception. If so, the transaction compensation mechanism is triggered, and the corresponding compensation strategy is executed according to the process configuration of the current business process; if not, Step S7 is executed. The triggering of the transaction compensation mechanism includes the reverse compensation mode and the forward compensation mode. The reverse compensation mode ensures the consistency of the service execution state under orchestration by calling the compensation service when the business service execution fails. Each request node is configured with a corresponding compensation service. After the business service execution fails, the compensation service restores the data to the state before the service execution, and the compensation service meets the idempotency requirement, ensuring that multiple repeated calls to the compensation service will not cause additional impacts on the business data. The forward compensation mode ensures the consistency of the service execution state under orchestration by continuously retrying the abnormal business service when the business service execution fails. Since the business services participating in the orchestration already meet the idempotency requirement, there is no need to configure a corresponding compensation service for each business service participating in the orchestration. Step S6 includes: judging the compensation mode of the current business process. If it is forward compensation, the forward compensation strategy is executed; if it is reverse compensation, the reverse compensation strategy is executed. The compensation mode is selected in the process configuration, and the default mode is reverse compensation.
[0066] The forward compensation strategy includes:
[0067] Step S601: The service orchestration data plane continuously performs backoff retries according to the retry configuration configured for the current request node, and judges whether the current abnormal node execution is successful. If so, the remaining process is continued, and the final processing result is returned to the client; if not, Step S602 is executed.
[0068] Step S602: Judge whether the number of retries reaches the retry threshold configured in the current request node. If so, the information of the business service with failed execution and the response result of the business service are recorded in the branch transaction information; if not, return to Step S601.
[0069] Step S603: Compose the information including process execution failure, abnormal business services, and abnormal response results into a complete response body and return it to the client all at once.
[0070] The reverse compensation strategy includes:
[0071] Step S611: The service orchestration data plane finds the list of branch transaction information corresponding to the current business process from the global cache. At this time, only the branch transactions that have been executed and completed are stored in the branch transaction list, and then traverse the branch transaction information list in reverse.
[0072] Step S612: Query the compensation service of the corresponding request node according to the branch transaction identifier in each branch transaction information. If no compensation service is found, it means that the request node does not require a compensation service when an exception occurs, and return to Step S611; if a compensation service is found, execute the compensation service and record the execution result and the number of retries in the corresponding branch transaction information. Specifically, perform back-off retries continuously according to the retry configuration configured for this request node, and record the number of retries of each branch transaction in the corresponding branch transaction information.
[0073] Step S613: Determine whether the compensation service is executed successfully. If so, execute Step S614; if not, execute Step S615.
[0074] Step S614: Determine whether all compensation services are executed. If so, return the information of process execution failure and successful transaction rollback to the client; if not, return to Step S612.
[0075] Step S615: Determine whether the number of retries reaches the retry threshold configured in the current request node. If so, record the information of the compensation service with failed rollback action and the response result of the compensation service in the branch transaction information, and then compose the information of process execution failure, transaction rollback failure, failed rollback compensation service, and the return response result of the compensation service into a complete response body and return it to the client all at once; if not, return to Step S612.
[0076] Step S7: Determine whether the current business process is executed. If so, the service orchestration data plane assembles the final result into a response body and returns it to the client; if not, return to Step S4. After returning the response body to the client, the service orchestration data plane will combine the list of branch transaction information corresponding to the business process in the global cache, record the execution log in the log file on the local data plane for subsequent process backtracking, and then delete the list of branch transaction information corresponding to this process in the global cache to complete transaction destruction.
[0077] Furthermore, in combination with the actual application scenario, the present invention is specifically described as follows. The users of service orchestration only need to use the visualization page provided by the control plane and combine the configuration specifications of distributed transactions to orchestrate a process that meets the distributed transaction processing capabilities as follows:
[0078] First, the user adds a process on the process management page of service orchestration and enters the required business attribute information for this process according to the page prompts. The user clicks the process drawing button at the end of the newly created process record to enter the process drawing page. The user clicks the global configuration button of the process on the process drawing page to expand the corresponding global configuration panel. In the global configuration panel, find the configuration area for data consistency guarantee. Turn on the switch for data consistency in the configuration area for data consistency guarantee. Then, the options for the corresponding transaction compensation mode will be displayed below the switch, and two modes, forward compensation and reverse compensation, can be selected, with the default being reverse compensation.
[0079] When configuring the corresponding request node during the process drawing, the process drawing page will require the user to enter the configuration required for this mode according to the corresponding transaction compensation mode.
[0080] 1) If the user selects the forward compensation mode, then the user is required to enter the maximum number of retries for the backoff retry strategy as needed below the transaction compensation mode option, with the default being 3 times. When configuring the corresponding request node during the subsequent process drawing, the user only needs to fill in the request information of the business service in the configuration panel of the request node. At the same time, the maximum number of retries for the backoff retry strategy can also be configured at the bottom of the configuration panel of each request node. The default retry times in each request node will inherit the configuration of the maximum number of retries for the forward compensation mode backoff retry strategy configured in the global configuration panel for this process. If the retry times are changed in the request node configuration panel, then when the process is actually executed, if an exception occurs in this request node and backoff retry is performed, the maximum number of retries configured for this node will be used.
[0081] 2) If the user selects the reverse compensation mode, then in addition to completing the configuration required for the forward compensation mode, the user also needs to configure the request information required for the corresponding compensation service for each request node in this process. The compensation service is not a mandatory item. If some business services participating in the orchestration do not need to perform compensation rollback actions when the process execution is abnormal and reverse compensation is performed, then such business services do not need to be configured with a compensation service. For example, some query-based business services.
[0082] Then, after completing the process drawing, the debugging function on the process drawing page can be used to perform online debugging on the process, and the corresponding business parameters are input to verify whether the processing process and return results of the process meet the expectations.
[0083] Finally, after completing the process debugging, you can click the publish button on the process drawing page to publish the debugged process to the data plane for external use.
[0084] Based on the reverse compensation transaction processing mechanism, the present invention can roll back the committed operations by executing reverse operations to ensure that the data can be rolled back to the state before execution, thereby achieving transaction consistency among all nodes. Each node is allowed to immediately commit the branch transaction after it is locally executed, without waiting for all nodes to complete, which significantly reduces the resource locking time and system waiting overhead. In addition, the present invention also introduces a forward compensation mechanism. When an abnormal node is encountered, the service orchestration data plane can quickly identify the abnormal node and re-initiate a request, and continue to execute the remaining process after the request is successful. This mechanism not only improves the fault tolerance of the system, but also makes the transaction consistency processing more flexible and efficient.
[0085] Embodiment 2
[0086] The present invention also provides a two-way compensation transaction consistency processing system for service orchestration. The two-way compensation transaction consistency processing system for service orchestration can be implemented by executing the process steps of the two-way compensation transaction consistency processing method for service orchestration. That is, those skilled in the art can understand the two-way compensation transaction consistency processing method for service orchestration as a preferred embodiment of the two-way compensation transaction consistency processing system for service orchestration.
[0087] According to the two-way compensation transaction consistency processing system for service orchestration provided by the present invention, it includes: a service orchestration control plane, a configuration center, and a service orchestration data plane.
[0088] The service orchestration control plane generates a business process and pushes it to the configuration center. The service orchestration control plane is responsible for performing operations including resource management, process drawing, process debugging, and process backtracking in a centralized and visual manner.
[0089] The service orchestration data plane reads the process configuration of the corresponding business process from the configuration center, starts a global transaction for the current business process, and registers an empty branch transaction list in the global cache of the service orchestration data plane. The global cache is used to store all branch transaction information of the current business process. Starting the global transaction includes generating a unique global transaction identifier and registering it in the global cache of the service orchestration data plane with the unique identifier as the key and an empty array as the value. The service orchestration data plane is responsible for providing a running environment for the published business processes in service orchestration. At the same time, as the transaction manager of distributed transactions when running processes, the data plane undertakes the responsibilities of registering, coordinating, and destroying distributed transactions.
[0090] The service orchestration data plane gradually executes each request node in the current business process; before each request node starts to execute, the service orchestration data plane assembles the initial branch transaction information using the unique identifier of the current request node as the corresponding branch transaction identifier. The branch transaction information is a hash structure, including the branch transaction identifier corresponding to the current request node, the execution start time, and the node execution status. After each request node is executed, the service orchestration data plane updates the corresponding branch transaction information of the current request node. The update of the corresponding branch transaction information includes adding the execution end time and updating the node execution status.
[0091] The updated branch transaction information of the current request node is sequentially stored in the branch transaction information list corresponding to the business process in the global cache, and it is judged whether the node has an execution exception. If so, the transaction compensation mechanism is triggered, and the corresponding compensation strategy is executed according to the process configuration of the current business process; if not, after all nodes are executed, the final processing result is returned to the client. The transaction compensation mechanism includes a reverse compensation mode and a forward compensation mode. The reverse compensation mode is to ensure the consistency of the service execution status under orchestration by calling the compensation service when the business service execution fails. Each request node is configured with a corresponding compensation service. After the business service execution fails, the compensation service restores the data to the state before the service execution, and the compensation service meets the idempotency requirement. The forward compensation mode is to ensure the consistency of the service execution status under orchestration by continuously retrying the abnormal business service when the business service execution fails.
[0092] The forward compensation strategy corresponding to the forward compensation mode includes: Module M601: The service orchestration data plane will continuously perform backoff retries according to the retry configuration configured for the current request node, and judge whether the current abnormal node execution is successful. If so, continue to execute the remaining process and return the final processing result to the client; if not, execute Module M602. Module M602: Judge whether the number of retries has reached the retry threshold configured in the current request node. If so, record the information of the business service with execution failure and the response result of the business service in the branch transaction information; if not, return to Module M601. Module M603: Compose the information including process execution failure, abnormal business service, and abnormal response result into a complete response body and return it to the client.
[0093] The reverse compensation strategy corresponding to the reverse compensation mode includes: Module M611: The service orchestration data plane finds the list of branch transaction information corresponding to the current business process from the global cache and traverses the list of branch transaction information in reverse. Module M612: Query the compensation service of the corresponding request node according to the branch transaction identifier in each piece of branch transaction information. If no compensation service is queried, it means that the request node does not require a compensation service when an exception occurs, and return to Module M611; if a compensation service is queried, execute the compensation service and record the execution result and the number of retries in the corresponding branch transaction information. Module M613: Determine whether the compensation service is executed successfully. If so, execute Module M614; if not, execute Module M615. Module M614: Determine whether all compensation services are executed. If so, return the information that the process execution fails and the transaction rollback is successful to the client; if not, return to Module M612. Module M615: Determine whether the number of retries reaches the retry threshold configured in the current request node. If so, record the information of the compensation service for which the rollback action fails and the response result of the compensation service in the branch transaction information, and then form a complete response body with the information that the process execution fails, the transaction rollback fails, the information of the compensation service for which the rollback fails, and the return response result of the compensation service and return it to the client; if not, return to Module M612.
[0094] After returning the response body to the client, the service orchestration data plane will combine the list of branch transaction information corresponding to the business process in the global cache, record the execution log in the log file of the data plane locally for subsequent process backtracking, and then delete the list of branch transaction information corresponding to the process in the global cache to complete the transaction destruction.
[0095] Those skilled in the art know that in addition to implementing the system and its various devices, modules, and units provided by the present invention in the form of pure computer-readable program code, the method steps can be logically programmed to enable the system and its various devices, modules, and units provided by the present invention to be implemented in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers to achieve the same function. Therefore, the system and its various devices, modules, and units provided by the present invention can be regarded as a hardware component, and the devices, modules, and units included therein for implementing various functions can also be regarded as the structures within the hardware component; the devices, modules, and units for implementing various functions can also be regarded as either software modules for implementing the method or structures within the hardware component.
[0096] The specific embodiments of the present invention have been described above. It should be understood that the present invention is not limited to the above specific embodiments, and those skilled in the art can make various changes or modifications within the scope of the claims, which do not affect the essence of the present invention. Without conflict, the embodiments of the present application and the features in the embodiments can be combined arbitrarily with each other.
Claims
1. A bidirectional compensation transaction consistency processing method for service orchestration, characterized in that: include: Step S1: The service orchestration control plane generates a business process and pushes it to the configuration center; Step S2: the service orchestration data plane reads the process configuration of the corresponding business process from the configuration center, opens a global transaction for the current business process, and registers an empty branch transaction list to the global cache of the service orchestration data plane; Step S3: The service orchestration data plane gradually executes each request node in the current business process; Step S4: before each request node starts executing, the service orchestration data plane uses the unique identifier of the current request node as the corresponding branch transaction identifier to assemble the initial branch transaction information; Step S5: After each request node completes execution, the service orchestration data plane updates the corresponding branch transaction information of the current request node; Step S6: Store the branch transaction information updated by the current requesting node in the branch transaction information list corresponding to the business process in the global cache in order, and determine whether the node is executed abnormally. If so, trigger the transaction compensation mechanism and execute the corresponding compensation strategy according to the process configuration of the current business process; if not, execute step S7; Step S7: Determine whether the current business process has been completed. If so, the service orchestration data plane assembles the final result response body and returns it to the client; if not, return to step S4.
2. The service-oriented bidirectional compensation transaction consistency processing method according to claim 1 is characterized in that: The service orchestration control plane is responsible for centrally performing operations including resource management, process drawing, process debugging, and process backtracking in a visual manner; The service orchestration data plane is responsible for providing a running environment for the published business processes in the service orchestration. At the same time, as the transaction manager of distributed transactions when running the process, the data plane assumes the responsibilities including registration, coordination, and destruction of distributed transactions.
3. The service-oriented bidirectional compensation transaction consistency processing method according to claim 1, characterized in that: The global cache is used to store all branch transaction information of the current business process; The step S2 includes generating a global transaction unique identifier, and registering the unique identifier as a key and an empty array as a value in a global cache of the service orchestration data plane; The branch transaction information is a hash structure, including the branch transaction identifier, execution start time, and node execution status corresponding to the current request node; The updating of the corresponding branch transaction information includes adding the execution end time and updating the node execution status.
4. The service-oriented bidirectional compensation transaction consistency processing method according to claim 1, characterized in that: The transaction compensation mechanism includes a reverse compensation mode and a forward compensation mode; The reverse compensation mode ensures the consistency of service execution status under the orchestration by calling the compensation service when the business service fails to execute. Each request node is configured with a corresponding compensation service. After the business service fails to execute, the compensation service restores the data to the state before the service execution, and the compensation service meets the idempotence requirement. The positive compensation mode ensures the consistency of service execution status under the arrangement by continuously retrying the abnormal business service when the business service execution fails.
5. The service-oriented bidirectional compensation transaction consistency processing method according to claim 4 is characterized in that: The forward compensation strategy corresponding to the forward compensation mode includes: Step S601: The service orchestration data plane will continuously perform backoff retries according to the retry configuration configured by the current request node, and determine whether the current abnormal node execution is successful. If so, continue to execute the remaining process and return the final processing result to the client; if not, execute step S602; Step S602: determine whether the number of retries reaches the retry threshold configured in the current request node. If yes, record the failed business service information and the business service response result in the branch transaction information; if no, return to step S601; Step S603: The information including the process execution failure, abnormal business service and abnormal response result is combined into a complete response body and returned to the client.
6. The service-oriented orchestration-oriented bidirectional compensation transaction consistency processing method according to claim 4, characterized in that: The reverse compensation strategies corresponding to the reverse compensation mode include: Step S611: the service orchestration data plane finds the branch transaction information list corresponding to the current business process from the global cache, and reversely traverses the branch transaction information list; Step S612: query the compensation service of the corresponding request node according to the branch transaction identifier in each branch transaction information. If no compensation service is found, it means that the request node does not need compensation service when an exception occurs, and return to step S611; if a compensation service is found, execute the compensation service and record the execution result and the number of retries in the corresponding branch transaction information; Step S613: Determine whether the compensation service is executed successfully, if yes, execute step S614; if no, execute step S615; Step S614: Determine whether all compensation services have been executed. If so, return the information of process execution failure and transaction rollback success to the client; if not, return to step S612; Step S615: Determine whether the number of retries reaches the retry threshold configured in the current request node. If so, record the compensation service information of the failed rollback and the response result of the compensation service in the branch transaction information, and then form a complete response body consisting of the process execution failure, transaction rollback failure, compensation service information of the failed rollback and the return response result of the compensation service and return it to the client; if not, return to step S612.
7. The service-oriented bidirectional compensation transaction consistency processing method according to claim 1, characterized in that: After returning the response body to the client, the service orchestration data plane will combine the branch transaction information list corresponding to the business process in the global cache, record the execution log in the local log file of the data plane, so as to facilitate subsequent process backtracking, and then delete the branch transaction information list corresponding to the process in the global cache to complete the transaction destruction.
8. A bidirectional compensation transaction consistency processing system for service orchestration, characterized in that: include: Service orchestration control plane, configuration center, and service orchestration data plane; The service orchestration control plane generates business processes and pushes them to the configuration center; The service orchestration data plane reads the process configuration of the corresponding business process from the configuration center, opens a global transaction for the current business process, and registers an empty branch transaction list to the global cache of the service orchestration data plane; The service orchestration data plane gradually executes each request node in the current business process; Before each request node starts executing, the service orchestration data plane uses the unique identifier of the current request node as the corresponding branch transaction identifier to assemble the initial branch transaction information; After each request node is executed, the service orchestration data plane updates the corresponding branch transaction information of the current request node; The branch transaction information updated by the current request node is stored in the branch transaction information list corresponding to the business process in the global cache in order, and it is determined whether the node is executed abnormally. If so, the transaction compensation mechanism is triggered, and the corresponding compensation strategy is executed according to the process configuration of the current business process; if not, the final processing result is returned to the client after all nodes are executed.
9. The service-oriented bidirectional compensation transaction consistency processing system according to claim 8, characterized in that: The global cache is used to store all branch transaction information of the current business process; The starting of the global transaction includes generating a global transaction unique identifier, and registering the unique identifier as a key and an empty array as a value in a global cache of the service orchestration data plane; The branch transaction information is a hash structure, including the branch transaction identifier, execution start time, and node execution status corresponding to the current request node; The updating of the corresponding branch transaction information includes adding the execution end time and updating the node execution status.
10. The service-oriented bidirectional compensation transaction consistency processing system according to claim 8, characterized in that: The transaction compensation mechanism includes a reverse compensation mode and a forward compensation mode; The reverse compensation mode ensures the consistency of service execution status under the orchestration by calling the compensation service when the business service fails to execute. Each request node is configured with a corresponding compensation service. After the business service fails to execute, the compensation service restores the data to the state before the service execution, and the compensation service meets the idempotence requirement. The positive compensation mode ensures the consistency of service execution status under the arrangement by continuously retrying the abnormal business service when the business service execution fails.
Citation Information
Patent Citations
Service orchestration processing method and device, electronic equipment and storage medium
CN116931945A
Strong-consistency distributed transaction processing system and method for service orchestration
CN118796361A
Cited By
Battery digital product passport generation system and method based on free flow arrangement
CN120562854A
Inventory consistency management method and device based on distributed transactions
CN120821535A