A chain-based business process management method and system supporting compensation rollback
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- XIAMEN HEXIN TECH CO LTD
- Filing Date
- 2026-07-10
- Publication Date
- 2026-08-07
AI Technical Summary
[0005]本发明提供了一种支持补偿回滚的链式业务流程管理方法及系统,旨在解决现有技术中链式业务流程在面对突发情况或异常时,传统补偿机制无法有效处理跨系统数据不一致、导致自动化流程中断并需要大量人工介入的问题
[0076]This application provides a chained business process management method and system that supports compensation rollback. The method receives the steps to be executed in a chained business process and performs pre-execution checks based on the DAG structure and the execution status of already executed steps to ensure that business steps are executed only when dependencies and resources are ready. After a business step executes successfully, a compensation dependency record containing reverse compensation operations is generated and appended to the chained compensation stack. This compensation stack maintains the reverse compensation operations of all successfully executed business steps in reverse DAG topology order. When a business step fails or triggers a rollback instruction, the system can execute the reverse compensation operations sequentially according to the order of the compensation stack, achieving chained compensation rollback. During the compensation process, the execution result of each reverse compensation operation is verified, and the compensation stack status is updated or nested compensation rollback is triggered based on the verification result. Finally, the business step execution history database is updated based on the execution result of the reverse compensation operations, and the updated history database is fed back to the pre-check and compensation stack, forming a chained compensation rollback closed loop covering the entire process.
Smart Images

Figure CN122529434A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of business process management technology, and more specifically, to a chain-based business process management method and system that supports compensation and rollback. Background Technology
[0002] In modern industrial production, complex industrial internet systems manage and execute chained business processes through a "directed acyclic graph data structure with task dependencies," ensuring the sequentiality of production, data consistency, and stable system operation. For example, equipment processing can only begin after material procurement is completed; this strict process arrangement ensures efficient operation under normal circumstances.
[0003] Due to the limitations of traditional compensation mechanisms, the material procurement system may roll back to an erroneous state, while the equipment scheduling and quality inspection systems continue to wait for materials from the main supplier, resulting in severe data inconsistencies between different systems throughout the chain-like business process. This deep-seated data inconsistency forces automated processes to halt, requiring technical personnel to perform complex and time-consuming manual data reconciliation and status correction, increasing operating costs and potentially causing production delays.
[0004] To address the aforementioned issues, existing technologies urgently need improvement. Summary of the Invention
[0005] This invention provides a chain-like business process management method and system that supports compensation and rollback, aiming to solve the problem that in the face of emergencies or anomalies, traditional compensation mechanisms cannot effectively handle cross-system data inconsistencies, leading to the interruption of automated processes and requiring a large amount of manual intervention.
[0006] The technical solution of this application is as follows:
[0007] Firstly, this application discloses a chain-like business process management method that supports compensation rollback, comprising the following steps:
[0008] Receive the steps to be executed in a chained business process. This chained business process consists of multiple business steps with dependencies organized according to a directed acyclic graph (DAG) structure. Each business step defines a forward execution operation and a corresponding reverse compensation operation.
[0009] Before executing the current business step, based on the DAG structure and the execution status of the already executed steps, a pre-execution check is performed on the current business step to generate a pre-check result that includes the dependency satisfaction status, resource readiness status, and the execution results of the preceding steps.
[0010] In response to the pre-check result being passed, the execution context of the current business step is activated, and the forward execution operation of the current business step is performed in the execution context; during the execution process, the execution progress status and intermediate data snapshots are collected in real time;
[0011] When the forward execution operation of the current business step is successfully executed, a compensation dependency record containing the reverse compensation operation is generated and the compensation dependency record is appended to the chained compensation stack; the chained compensation stack maintains the reverse compensation operations of all successfully executed business steps in reverse order of the DAG topology.
[0012] When the forward execution operation of the current business step fails or the chain business process triggers a rollback instruction, the reverse compensation operation of each successfully executed business step is executed in sequence from top to bottom of the chain compensation stack to achieve chain compensation rollback.
[0013] During the execution of this reverse compensation operation, a compensation execution verification is performed on the execution result of each reverse compensation operation, and the stack state of the chained compensation stack is updated or a nested compensation rollback is triggered based on the result of the compensation execution verification.
[0014] Based on the execution result of the reverse compensation operation, the business step execution history database is updated, and the updated business step execution history database is fed back to the pre-inspection step and the chain compensation stack, forming a chain compensation rollback closed loop covering the entire process.
[0015] Through this technical solution, this application can build a chain-like business process management mechanism with adaptive compensation and rollback capabilities, effectively solving the problem that traditional compensation mechanisms fail to understand real-time state deviations and cross-system dependencies in complex business scenarios, thereby improving the robustness and automation level of business processes.
[0016] Furthermore, this chain-like business process, organized into multiple dependent business steps according to a directed acyclic graph (DAG) structure, includes the following steps:
[0017] Based on the business process definition file, the chain-like business process is parsed using BPMN 2.0 or the Workflow Network WfMC standard to obtain a flowchart containing a set of nodes, a set of directed edges, and node attributes.
[0018] Perform a topological sort on the flowchart to generate a DAG topological sequence of the chained business process; in this DAG topological sequence, the prerequisite dependent steps of each business step are all located before the corresponding business step.
[0019] Define the input parameter contract and output parameter contract for the forward execution operation and the compensation input parameter contract and compensation output parameter contract for the corresponding reverse compensation operation for each business step in the DAG topology sequence;
[0020] Based on the input parameter contract, the output parameter contract, the compensation input parameter contract, and the compensation output parameter contract, construct the DAG structure definition of the chained business process.
[0021] Through this technical solution, this application can ensure the structured and resolvable nature of business processes by standardizing process definitions and topology sorting, providing accurate dependencies and operation definitions for subsequent pre-execution checks and chain-like compensation rollbacks, thereby improving the standardization and controllability of process management.
[0022] Based on this, the pre-execution check steps for the current business step, performed before execution based on the DAG structure and the execution status of already executed steps, include:
[0023] Based on this DAG structure, determine all the preceding dependent steps of the current business step;
[0024] Retrieve the latest execution status and result data of all preceding dependent steps from the business step execution history database;
[0025] Based on the latest execution status and the execution result data, verify whether all the prerequisite dependency steps have been executed successfully.
[0026] Obtain the resource status required for the execution of the current business step, including database connection status, lock resource status, and external service availability status;
[0027] Based on the execution status of all the preceding dependent steps and the resource status, generate a pre-detection result that includes the dependency satisfaction status, resource readiness status, and the execution results of the preceding steps.
[0028] Through this technical solution, this application can effectively identify potential dependency non-compliance or resource unavailability issues before business steps are executed through comprehensive pre-execution inspection, thereby avoiding invalid execution and subsequent compensation costs, and improving the execution efficiency and stability of business processes.
[0029] Furthermore, the step of generating a compensation dependency record containing the reverse compensation operation when the forward execution operation of the current business step is successful includes:
[0030] When the forward execution operation of the current business step is successfully executed, capture a snapshot of the input parameters, a snapshot of the output parameters, and the execution context identifier of the current business step;
[0031] Based on the DAG node definition of the current business step, find the corresponding reverse compensation operation definition;
[0032] According to the compensation input parameter contract of the reverse compensation operation, the compensation input parameters are extracted from the input parameter snapshot and the output parameter snapshot.
[0033] The compensation input parameters, the reverse compensation operation definition, the execution context identifier, and the capture timestamp are encapsulated into a compensation dependency record;
[0034] The compensation dependency record is appended to the chained compensation stack.
[0035] Through this technical solution, this application can capture execution snapshots and parameters in real time and encapsulate them with the reverse compensation operation definition as a compensation dependency record, ensuring that all the context information required for compensation can be accurately obtained when rollback is needed, thereby improving the accuracy and reliability of the compensation operation.
[0036] In some preferred embodiments, the chained compensation stack maintains the reverse compensation operations for all successfully executed business steps in reverse order of the DAG topology, including the following steps:
[0037] The push order of the chain compensation stack is constructed according to the reverse order of the DAG topology, ensuring that the reverse compensation operation of the business step executed later is located at the top of the stack, and the reverse compensation operation of the business step executed earlier is located at the bottom of the stack.
[0038] Each stack frame of the chained compensation stack is appended with a unique stack frame identifier, an execution timestamp, and a compensation dependency identifier;
[0039] When multiple branches of the chained business process are executed in parallel, an independent chained compensation stack is maintained for each branch, and a merging operation of the chained compensation stack is performed at the branch merging point; the merging operation includes stack frame deduplication, conflict detection, and priority adjudication.
[0040] Through this technical solution, this application can ensure the sequentiality, atomicity, and consistency of compensation rollback in complex parallel processes by reversing the order of compensation operations and supporting the merging of compensation stacks for parallel branches, thereby effectively handling the compensation needs of multi-branch business processes.
[0041] As a technical improvement, the steps of performing compensation execution verification on the execution result of each reverse compensation operation during the execution of the reverse compensation operation, and updating the stack state of the chained compensation stack or triggering nested compensation rollback based on the result of the compensation execution verification include:
[0042] Before each reverse compensation operation is executed, a compensation execution pre-check is performed to check the resource status required for compensation and the compensation execution status of dependent steps.
[0043] Execute the reverse compensation operation and collect the progress status and results of the compensation execution in real time;
[0044] Perform compensation execution verification on the compensation execution result. The compensation execution verification includes at least one of the following: compensation idempotency verification, compensation consistency verification, and compensation integrity verification.
[0045] When the compensation execution verification passes, the corresponding stack frame is popped from the chained compensation stack;
[0046] When the compensation execution verification fails, a nested compensation rollback is triggered from the corresponding stack frame of the chained compensation stack according to the predefined nested compensation rules. The nested compensation rollback includes recursively calling the compensation operation of the reverse compensation operation until the maximum nesting depth is reached or all compensation execution verifications pass.
[0047] This technical solution ensures the correctness and thoroughness of compensation operations by introducing compensation execution verification and nested compensation rollback mechanisms. Even if anomalies occur during the compensation process, the system can self-repair, thereby significantly improving the success rate of compensation rollback and the overall stability of the system.
[0048] As a further improvement, after triggering a nested rollback from the corresponding stack frame of the chained compensation stack according to predefined nested compensation rules when the compensation execution verification fails, the following steps are also included:
[0049] When the nested compensation rollback reaches the preset maximum nesting depth and there are still compensation execution verification failures, the remaining uncompensated stack frames in the chained compensation stack are marked as pending manual intervention.
[0050] Generate a manual intervention work order and push the context information, compensation dependency record, compensation execution result, and nested compensation history of the stack frame corresponding to the state requiring manual intervention to the business operations and maintenance personnel.
[0051] Receive processing instructions from business operations and maintenance personnel for the manual intervention work order, and perform the final compensation operation or mark it as an uncompensable anomaly based on the processing instructions.
[0052] Through this technical solution, this application can provide final protection for complex or non-automatically repairable compensation scenarios by introducing a manual intervention mechanism when nested compensation fails, thereby avoiding system deadlock or permanent data inconsistency and realizing a closed-loop compensation system for human-machine collaboration.
[0053] To improve the solution, the steps to update the business step execution history database based on the execution result of the reverse compensation operation include:
[0054] For each business step, a structured execution record is generated, which includes the business step identifier, execution timestamp, execution result, compensation execution result, and final status.
[0055] Write the structured execution record into the business step execution history database in an immutable log format;
[0056] Based on the historical execution results in the execution history database of this business step, the success rate, average execution time, compensation trigger rate, and compensation success rate of each business step are statistically analyzed to obtain the statistical characteristics of business step execution.
[0057] The statistical characteristics of the business step are fed back to the pre-execution inspection step and the chained compensation stack to optimize the dependency satisfaction threshold of the pre-execution inspection and the compensation triggering conditions of the chained compensation stack.
[0058] Through this technical solution, this application can continuously update and analyze the historical database of business step execution, providing data-driven optimization basis for pre-inspection and compensation mechanisms, realizing adaptive and intelligent process management, thereby continuously improving the performance and reliability of the system.
[0059] To enhance functionality, after the step of generating a compensation dependency record containing the reverse compensation operation when the forward execution operation of the current business step is successful, the following steps are also included:
[0060] Perform deviation identification on the execution result of the current business step, which includes anomaly deviation identification and performance deviation identification;
[0061] When an abnormal deviation or performance deviation is detected, the corresponding reverse compensation operation is marked as a high-priority compensation operation, and the priority of the corresponding stack frame in the chained compensation stack is adjusted.
[0062] When the abnormal deviation reaches the preset severity level, an active rollback command is triggered to perform preventative compensation rollback on the current business step and subsequent unexecuted business steps.
[0063] Through this technical solution, this application can identify and correct potential risks in the early stages of a problem by introducing deviation identification and proactive rollback mechanisms, transforming passive compensation into proactive prevention, thereby significantly reducing the risk and loss of business interruption.
[0064] Secondly, this application also discloses a chain-based business process management system that supports compensation rollback, used to implement the above method. The system includes:
[0065] The process modeling module is configured to build a DAG structure definition that includes business steps, prerequisites, forward execution operations, and reverse compensation operations based on the business process definition file.
[0066] The pre-inspection execution module communicates with the process modeling module and is configured to perform a pre-inspection on the current business step based on the DAG structure definition and the execution status of the executed steps.
[0067] The business execution engine communicates with the pre-inspection execution module, is configured to activate the execution context and perform forward execution operations, and collects execution progress status and intermediate data snapshots in real time.
[0068] The chain compensation stack manager communicates with the business execution engine and is configured to maintain the reverse compensation operations of all successfully executed business steps in reverse order of DAG topology.
[0069] The compensation execution engine communicates with the chained compensation stack manager and is configured to perform reverse compensation operations sequentially from the top to the bottom of the chained compensation stack, and to perform compensation execution verification.
[0070] The nested compensation controller communicates with the compensation execution engine and is configured to trigger nested compensation rollback based on the result of compensation execution verification, and switch to manual intervention mode when the maximum nesting depth is reached.
[0071] The deviation identification and proactive rollback module is connected to the business execution engine and the chain compensation stack manager respectively, and is configured to perform deviation identification on the execution result and trigger proactive rollback instructions;
[0072] The execution history library module communicates with the business execution engine, the compensation execution engine, and the nested compensation controller, respectively, and is configured to persistently store structured execution records and maintain the statistical characteristics of business step execution.
[0073] The process modeling module, the pre-inspection execution module, the business execution engine, the chain compensation stack manager, the compensation execution engine, the nested compensation controller, the deviation identification and active rollback module, and the execution history library module constitute a chain compensation rollback closed loop covering the entire process.
[0074] This technical solution provides a complete system that integrates process modeling, pre-inspection, execution, compensation, nested compensation, deviation identification, and historical records. Through modular design and closed-loop feedback mechanism, it enables comprehensive and intelligent management of complex chain-like business processes, thereby effectively improving the system's automation, stability, and maintainability.
[0075] Beneficial effects
[0076] This application provides a chained business process management method and system that supports compensation rollback. The method receives the steps to be executed in a chained business process and performs pre-execution checks based on the DAG structure and the execution status of already executed steps to ensure that business steps are executed only when dependencies and resources are ready. After a business step executes successfully, a compensation dependency record containing reverse compensation operations is generated and appended to the chained compensation stack. This compensation stack maintains the reverse compensation operations of all successfully executed business steps in reverse DAG topology order. When a business step fails or triggers a rollback instruction, the system can execute the reverse compensation operations sequentially according to the order of the compensation stack, achieving chained compensation rollback. During the compensation process, the execution result of each reverse compensation operation is verified, and the compensation stack status is updated or nested compensation rollback is triggered based on the verification result. Finally, the business step execution history database is updated based on the execution result of the reverse compensation operations, and the updated history database is fed back to the pre-check and compensation stack, forming a chained compensation rollback closed loop covering the entire process.
[0077] Through the above technical solution, this application effectively solves the problem in existing technologies where, when actual operation deviates from the system's logical model, traditional compensation mechanisms cannot correctly understand the root cause of data inconsistency, leading to compensation failure, severe data inconsistency, and the need for extensive manual intervention. This application introduces a pre-execution inspection mechanism to identify dependency non-compliance and resource unavailability in advance, avoiding invalid execution. By constructing a chained compensation stack and maintaining compensation operations in reverse order according to the DAG topology, the logical correctness and completeness of compensation rollback are ensured. More importantly, the introduction of compensation execution verification and nested compensation rollback mechanisms enables the system to self-repair during the compensation process, significantly improving the success rate and thoroughness of compensation. Furthermore, the feedback mechanism of the business step execution history database allows the system to continuously optimize pre-inspection and compensation strategies, achieving adaptive and intelligent process management. Therefore, this application can significantly improve the robustness, automation level, and data consistency of complex chained business processes, reduce manual intervention, lower operating costs, and effectively avoid production plan delays. Attached Figure Description
[0078] Figure 1 This is a flowchart illustrating a chain-based business process management method that supports compensation and rollback, provided by an embodiment of the present invention.
[0079] Figure 2 This is a schematic diagram of the structure of a chain-type business process management system that supports compensation rollback, provided by an embodiment of the present invention. Detailed Implementation
[0080] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0081] Reference Figure 1 , Figure 1 This is a flowchart illustrating a chain-like business process management method supporting compensation rollback provided by an embodiment of the present invention, including:
[0082] S11, Receive the steps to be executed in the chained business process. The chained business process is organized by multiple business steps with dependencies according to the directed acyclic graph (DAG) structure. Each business step defines a forward execution operation and a corresponding reverse compensation operation.
[0083] S12, Before executing the current business step, based on the DAG structure and the execution status of the already executed steps, perform a pre-execution check on the current business step and generate a pre-check result that includes the dependency satisfaction status, resource readiness status and the execution result of the previous step;
[0084] S13, in response to the pre-inspection result being passed, activate the execution context of the current business step and execute the forward execution operation of the current business step in the execution context; during the execution process, collect the execution progress status and intermediate data snapshots in real time;
[0085] S14. When the forward execution operation of the current business step is successfully executed, a compensation dependency record containing the reverse compensation operation is generated and the compensation dependency record is appended to the chained compensation stack. The chained compensation stack maintains the reverse compensation operations of all successfully executed business steps in reverse order of the DAG topology.
[0086] S15, when the forward execution operation of the current business step fails or the chain business process triggers a rollback instruction, the reverse compensation operation of each successfully executed business step is executed in sequence from top to bottom of the chain compensation stack to achieve chain compensation rollback.
[0087] S16, During the execution of the reverse compensation operation, the execution result of each reverse compensation operation is verified, and the stack state of the chain compensation stack is updated or the nested compensation rollback is triggered based on the result of the verification.
[0088] S17. Based on the execution result of the reverse compensation operation, update the business step execution history database and feed the updated business step execution history database back to the pre-inspection step and the chain compensation stack to form a chain compensation rollback closed loop covering the entire process.
[0089] To better understand the technical solution proposed in this application, this application first explains some key terms involved therein.
[0090] A "chain-like business process" refers to a business process composed of multiple interdependent business steps executed in a specific order. The dependencies between these business steps can typically be represented as a directed acyclic graph (DAG) structure, ensuring the logical flow and sequential execution of the process. For example, an order processing flow might include business steps such as "receiving an order," "checking inventory," "processing payment," and "shipping," where "checking inventory" depends on "receiving an order," "processing payment" depends on "checking inventory," and so on.
[0091] "Forward execution operations" refer to the specific tasks or functions that each business step needs to complete in the normal process. For example, in the "payment processing" business step, the forward execution operation might be to call the payment gateway interface to complete the deduction.
[0092] "Reverse compensation operation" refers to an operation used to undo the effects of a business step's execution when the forward execution of a business step fails or the entire chain of business processes needs to be rolled back. For example, if "payment processing" fails, its reverse compensation operation might be a refund.
[0093] A "DAG structure" refers to a directed acyclic graph structure used to represent dependencies between business steps. In this structure, nodes represent business steps, directed edges represent dependencies, and there are no cycles in the graph.
[0094] "Execution context" refers to the runtime environment that provides the necessary environment and data for executing a specific business step. This may include input parameters, temporary variables, system configurations, etc.
[0095] "Compensation dependency records" refer to structured data used to record information required for reverse compensation operations after a business step has been successfully executed. This information may include the definition of the reverse compensation operation, a snapshot of the parameters required to execute the operation, and an execution context identifier, etc.
[0096] A "chained compensation stack" is a data structure used to maintain reverse compensation operations for all successfully executed business steps in a specific order (usually the reverse of the DAG topology). When a rollback is needed, the compensation operations can be executed sequentially according to the LIFO (Last-In, First-Out) principle of the stack.
[0097] "Compensation execution verification" refers to the process of verifying the compensation result after performing a reverse compensation operation to ensure the correctness, idempotency, consistency, and completeness of the compensation operation.
[0098] The method proposed in this application can be implemented in various industrial internet systems, enterprise resource planning (ERP) systems, supply chain management (SCM) systems, and other scenarios that require handling complex chain-like business processes. For example, in a smart manufacturing system, the entire process from raw material procurement, production scheduling, equipment processing to product delivery can be regarded as a chain-like business process, and the method of this application can effectively manage and roll back any anomalies in it.
[0099] The core of the chain business process management method with support for compensation and rollback proposed in this application lies in building a robust compensation and rollback mechanism to deal with various abnormal situations in complex chain business processes.
[0100] First, when receiving the steps to be executed in a chained business process, the chained business process is defined as multiple business steps with dependencies organized according to a directed acyclic graph (DAG) structure. Each business step defines not only its "forward execution operation" but also its corresponding "backward compensation operation." For example, in an e-commerce order processing flow, "creating an order" is a business step, whose forward execution operation is generating an order record, and its backward compensation operation is canceling the order; "deducting payment" is another business step, whose forward execution operation is calling the payment interface to complete the deduction, and its backward compensation operation is initiating a refund. This two-way definition ensures that each business step is rollbackable.
[0101] Before executing the current business step, a "pre-execution check" is performed based on the DAG structure and the execution status of already executed steps. The pre-check process generates a pre-check result that includes dependency satisfaction status, resource readiness status, and the execution results of the preceding steps. For example, before executing the "deduction" business step, the system checks whether the "create order" business step has been successfully completed (dependency satisfaction status), whether the payment gateway is available (resource readiness status), and whether the output of the "create order" step (e.g., order number) is correct (pre-step execution result). Pre-checks can be implemented in several ways. For example, a pre-check rule engine can be configured to evaluate dependencies, resource status, and preceding results based on a predefined set of rules. Another approach is to query a centralized state management service to obtain all relevant information and make a comprehensive judgment.
[0102] In response to a successful pre-check, the system activates the "execution context" of the current business step and performs the "forward execution operation" within it. During execution, the system continuously monitors the execution progress and captures intermediate data snapshots. For example, when the "deduction" business step is activated, it is assigned a unique transaction ID and loaded with input parameters such as the order number and payment amount. During the deduction process, the system records the call status of the payment interface (e.g., "pending payment," "paying," "payment successful") and captures intermediate data snapshots such as the transaction serial number returned by the payment gateway. Activation of the execution context can be achieved by creating a separate thread or process that encapsulates all the environmental information required for the business step's execution. Real-time monitoring of the execution progress and intermediate data snapshots can be achieved by embedding logging or event-triggered mechanisms within the business step's code.
[0103] When the forward execution of the current business step is successful, the system generates a "compensation dependency record" containing reverse compensation operations and appends this record to the "chained compensation stack." The chained compensation stack maintains the reverse compensation operations of all successfully executed business steps in reverse DAG topological order. For example, if the "deduction" business step is successful, the system generates a compensation dependency record containing the definition of the "refund" operation, the transaction serial number at the time of deduction, the order number, and other information, and pushes it onto the chained compensation stack. Since "deduction" is executed after "order creation," the reverse compensation operation for "deduction" is located above the reverse compensation operation for "order creation" in the chained compensation stack, ensuring that a refund is processed before order cancellation during rollback. The chained compensation stack can be implemented based on an in-memory stack structure or persisted to a database to ensure no data loss.
[0104] When the forward execution of the current business step fails or a rollback instruction is triggered in the chained business process, the system executes the reverse compensation operations of each successfully executed business step in the order from top to bottom of the chained compensation stack, thus achieving chained compensation rollback. For example, if the subsequent "shipping" business step fails, or the user actively cancels the order, triggering a rollback, the system will first pop the "refund" operation corresponding to "deduction" from the chained compensation stack and execute it, then pop the "cancel order" operation corresponding to "create order" and execute it. This reverse execution ensures that the business process can be gradually and orderly restored to a consistent state. The rollback instruction can be triggered automatically (e.g., by the system detecting an error) or manually (e.g., by the user interface).
[0105] During the execution of reverse compensation operations, the system performs a "compensation execution verification" on the result of each reverse compensation operation, and updates the stack state of the chained compensation stack or triggers nested compensation rollback based on the verification result. For example, after executing a "refund" operation, the system verifies whether the refund was successful, whether the refund amount is correct, and whether the payment status has been updated to "refunded." If the verification fails, such as due to a timeout in the refund API call, the system may mark the compensation operation as "pending retry" and trigger a nested compensation rollback to attempt to execute the refund operation again or execute other alternative compensation strategies. Compensation execution verification can be implemented through predefined verification rules or callback functions, which are called after the compensation operation is executed.
[0106] Finally, based on the execution result of the reverse compensation operation, the system updates the "Business Step Execution History Database" and feeds the updated database back to the pre-execution inspection step and the chained compensation stack, forming a chained compensation rollback closed loop covering the entire process. For example, if the "refund" operation is successful, the status of the "deduction" step in the business step execution history database will be updated to "compensated." This updated historical data will affect subsequent pre-execution inspections (e.g., avoiding duplicate execution of compensated steps) and the chained compensation stack (e.g., adjusting compensation strategies in certain situations), thus forming an adaptive, self-correcting closed-loop management mechanism. The business step execution history database can be a distributed database used to store the execution records and compensation records of all business steps.
[0107] The chain-based business process management method with support for compensation rollback proposed in this application aims to solve the problem in traditional chain-based business process management where unforeseen circumstances cause deviations between the internal logic of the system and actual operations, leading to data inconsistency and failure of the compensation mechanism.
[0108] In some embodiments of this application, the chained business process is organized into multiple dependent business steps according to a directed acyclic graph (DAG) structure. Specifically, the chained business process, organized into multiple dependent business steps according to a DAG structure, may further include:
[0109] Based on the business process definition file, the chained business process is parsed using BPMN 2.0 or the Workflow Network WfMC standard to obtain a flowchart containing a set of nodes, a set of directed edges, and node attributes.
[0110] Perform topological sorting on the flowchart to generate a DAG topological sequence of the chained business process; in the DAG topological sequence, the prerequisite dependent steps of each business step are all located before the corresponding business step;
[0111] Define the input parameter contract and output parameter contract for the forward execution operation and the compensation input parameter contract and compensation output parameter contract for the corresponding reverse compensation operation for each business step in the DAG topology sequence;
[0112] Based on the input parameter contract, the output parameter contract, the compensation input parameter contract, and the compensation output parameter contract, construct the DAG structure definition of the chained business process.
[0113] Specifically, when constructing the DAG structure of a chained business process, the first step is to parse the chained business process according to the business process definition file. The business process definition file can be described using the widely accepted BPMN 2.0 (Business Process Model and Symbols 2.0) or WfMC (Workflow Management Consortium) standards. Through parsing, a flowchart containing a set of nodes, a set of directed edges, and node attributes can be obtained. The node set represents each business step in the business process, the set of directed edges represents the dependencies and flow directions between business steps, and the node attributes contain detailed information about each business step, such as its functional description and execution conditions.
[0114] Furthermore, to ensure the correct execution order of the business steps, a topological sort needs to be performed on the flowchart. Topological sorting is a method for linearly sorting the vertices of a directed acyclic graph (DAG) such that for each directed edge uv in the graph, u always appears before v in the sort. Through topological sorting, a DAG topological sequence of the chained business process can be generated. This sequence guarantees that the prerequisite dependent steps of each business step are all located before the corresponding business step, thus providing a clear sequential basis for subsequent business execution.
[0115] Based on this, for each business step in the DAG topology sequence, input parameter contracts and output parameter contracts for forward execution operations, and compensation input parameter contracts and compensation output parameter contracts for corresponding reverse compensation operations are defined. The input parameter contracts specify the data types and formats that the business step needs to receive before execution, while the output parameter contracts define the data types and formats that will be generated after the business step is executed. Similarly, the compensation input parameter contracts and compensation output parameter contracts define the inputs and outputs required for the reverse compensation operation, respectively. These contracts serve as interface specifications for the business steps, ensuring the correct transmission and compatibility of data between different business steps and between forward execution and reverse compensation.
[0116] Finally, based on the predefined input parameter contract, output parameter contract, compensation input parameter contract, and compensation output parameter contract, the DAG structure definition of the chained business process can be constructed. This DAG structure definition not only includes the topological relationship of the business steps but also encapsulates the execution and compensation interface specifications for each step, forming a complete and executable business process model.
[0117] This application's solution employs standardized business process definition documents for parsing and combines topological sorting to generate a strict DAG topology sequence, ensuring the structured and manageable nature of the chained business process. By defining clear parameter contracts for each business step and its compensation operation, the dependencies and data flow between business steps are clearly defined, providing a solid foundation for subsequent pre-execution checks, business execution, and chained compensation rollback. This clear structural definition helps the system accurately understand business logic, effectively identify and manage dependencies between business steps, thereby improving the robustness and maintainability of the entire business process.
[0118] Specifically, the pre-execution check step for the current business step, based on the DAG structure and the execution status of already executed steps, can be further refined into the following process:
[0119] The step of performing a pre-execution check on the current business step before execution, based on the DAG structure and the execution status of already executed steps, includes:
[0120] Based on the DAG structure, determine all the preceding dependent steps of the current business step;
[0121] The Directed Acyclic Graph (DAG) structure clearly defines the dependencies between business steps. Before executing any business step, the system uses this DAG structure to accurately identify all prerequisite steps that must be successfully completed before it. This aims to ensure that the logical order of the business process is strictly adhered to, avoiding execution errors caused by unmet dependencies.
[0122] Retrieve the latest execution status and result data of all the preceding dependent steps from the business step execution history database;
[0123] Specifically, to assess the completion status of preceding dependent steps, the system queries the business step execution history database. This database records detailed information about all executed business steps, including their execution status (e.g., success, failure, in progress) and execution result data. By obtaining this latest data, the actual completion status of preceding dependencies can be accurately determined.
[0124] Based on the latest execution status and the execution result data, verify whether all the prerequisite dependency steps have been executed successfully.
[0125] Furthermore, after obtaining the execution status and result data of the preceding dependent steps, the system will perform rigorous verification. This verification aims to confirm whether all preceding dependent steps have been executed successfully as expected. The failure or incompleteness of any preceding dependent step will cause the current business step to fail the pre-check, thereby effectively preventing the potential spread of errors.
[0126] Obtain the resource status required for the execution of the current business step, including database connection status, lock resource status, and external service availability status;
[0127] In addition to dependency verification, the system also checks the status of various resources required for the execution of the current business step. These resources may include, but are not limited to, the availability of database connections, the occupancy of critical lock resources, and the accessibility of external services. Ensuring that these resources are ready before execution is crucial to guaranteeing the smooth execution of the business step.
[0128] Based on the execution status of all the preceding dependent steps and the resource status, a pre-detection result is generated, which includes the dependency satisfaction status, resource readiness status, and the execution results of the preceding steps.
[0129] Finally, based on the combined results of the above checks, the system will generate a comprehensive pre-check result. This pre-check result will clearly indicate whether dependencies are satisfied, whether required resources are ready, and summarize the execution results of the preceding steps. This pre-check result is the final basis for determining whether the current business step can continue.
[0130] This application's solution ensures the robustness and reliability of business processes by systematically performing pre-execution checks before the current business step is executed. Through this technical solution, the application introduces a multi-dimensional pre-check mechanism before business step execution, significantly improving the reliability and stability of chained business processes. This solution can not only effectively identify and prevent business interruptions caused by unmet or failed prerequisite dependencies, but also proactively detect and resolve issues such as insufficient resources or unavailable external services. This allows business processes to run in a more deterministic environment, reducing the frequency of runtime errors and rollback operations, thereby improving the overall efficiency and success rate of the business process. Furthermore, through detailed pre-check results, the system can provide more accurate basis for subsequent decisions, further optimizing the management and control of business processes.
[0131] In some of the embodiments described above in this application, when the forward execution operation of the current business step is successfully executed, the step of generating a compensation dependency record containing the reverse compensation operation can be further refined to ensure the completeness and accuracy of the compensation information.
[0132] Specifically, when the forward execution operation of the current business step in the above method is successful, the step of generating a compensation dependency record containing the reverse compensation operation includes:
[0133] When the forward execution operation of the current business step is successfully executed, capture a snapshot of the input parameters, a snapshot of the output parameters, and the execution context identifier of the current business step;
[0134] Based on the DAG node definition of the current business step, find the corresponding reverse compensation operation definition;
[0135] Based on the compensation input parameter contract of the reverse compensation operation, the compensation input parameters are extracted from the input parameter snapshot and the output parameter snapshot.
[0136] The compensation input parameters, reverse compensation operation definition, execution context identifier, and capture timestamp are encapsulated into a compensation dependency record;
[0137] Add compensation dependency records to the chained compensation stack.
[0138] When the forward execution of the current business step is successfully completed, the system immediately captures key information about the execution of that step. This information includes a snapshot of the input parameters for that step, i.e., the instantaneous state of all parameters received before execution; a snapshot of the output parameters, i.e., the instantaneous state of all result parameters generated after successful execution; and an execution context identifier, used to uniquely identify the execution instance of this business step. These snapshots and identifiers form the basis for subsequent precise compensation operations.
[0139] Furthermore, to determine how to perform compensation, it is necessary to locate the pre-associated reverse compensation operation definition based on the node definition of the current business step in the DAG structure. Each business step's forward execution operation and corresponding reverse compensation operation are clearly defined during design; therefore, the corresponding compensation logic can be accurately obtained through the DAG node definition. After obtaining the reverse compensation operation definition, the parameters required for the compensation operation need to be precisely extracted from the previously captured input parameter snapshots and output parameter snapshots according to the compensation input parameter contract required for this operation. The compensation input parameter contract defines the data format and content required for the reverse compensation operation, ensuring that the compensation operation receives correct and complete data.
[0140] Subsequently, the extracted compensation input parameters, the found reverse compensation operation definitions, the captured execution context identifiers, and the capture timestamps are encapsulated into a complete compensation dependency record. This record is the smallest unit for executing the reverse compensation operation and contains all the necessary information required for compensation. Finally, the encapsulated compensation dependency record is appended to the chained compensation stack. The chained compensation stack maintains the reverse compensation operations of all successfully executed business steps in reverse order of the DAG topology, ensuring that compensation operations can be executed in the correct reverse order when rollback is required.
[0141] This application's solution immediately and comprehensively captures the execution state, parameter snapshots, and compensation operation definitions of a business step upon successful forward execution, encapsulating these into a structured compensation dependency record. This mechanism ensures that complete, accurate, and traceable compensation information is available when subsequent compensation rollbacks are triggered. By capturing input and output parameter snapshots, the context of the business step's execution can be accurately reconstructed, avoiding compensation failures due to data loss or inconsistency. The correctness of the compensation logic is guaranteed by searching the reverse compensation operations defined in the DAG node. Encapsulating this information into compensation dependency records and appending them to the chained compensation stack provides a solid data foundation and operational basis for subsequent chained compensation rollbacks, enabling compensation operations to precisely reverse-process executed business steps, thereby effectively resolving errors or anomalies in the business process.
[0142] In some embodiments described above in this application, a chained compensation stack is proposed to maintain the reverse compensation operations of all successfully executed business steps in reverse order of the DAG topology. However, ensuring the correct construction and effective management of this compensation stack, as well as data consistency and operation order in complex business scenarios (such as parallel branches), are issues that require further consideration. Failure to address these issues may lead to incorrect compensation rollback order, data loss, or conflicts in compensation operations, thereby affecting the reliability and accuracy of the entire chained business process. To address this, this application further proposes an optimized maintenance method for the chained compensation stack. By explicitly defining the stack insertion order, attaching unique identifiers, and handling parallel branch merging, the correctness and robustness of compensation rollback can be ensured.
[0143] The above-mentioned chained compensation stack maintains the reverse compensation operations for all successfully executed business steps in reverse order of the DAG topology. The steps include:
[0144] The chain compensation stack is constructed in reverse order of the DAG topology to ensure that the reverse compensation operation of the later executed business step is at the top of the stack and the reverse compensation operation of the earlier executed business step is at the bottom of the stack.
[0145] Each stack frame of the chained compensation stack is appended with a unique stack frame identifier, an execution timestamp, and a compensation dependency identifier;
[0146] When multiple branches of the chained business process are executed in parallel, an independent chained compensation stack is maintained for each branch, and a merging operation of the chained compensation stack is performed at the branch merging point; the merging operation includes stack frame deduplication, conflict detection, and priority adjudication.
[0147] Specifically, the stacking order of the chained compensation stack, constructed in reverse order of the DAG topological order, means that after a business step's forward execution operation is successfully completed, its corresponding reverse compensation operation is encapsulated as a compensation dependency record and appended to the chained compensation stack. Since business steps are executed forward according to the DAG topological order, business steps that succeed later are usually located further back in the topological order. When the reverse compensation operations of these business steps are pushed onto the stack sequentially, naturally, the reverse compensation operations of the later-executed business steps will be at the top of the stack, while the reverse compensation operations of the earlier-executed business steps will be at the bottom. This mechanism ensures that when a rollback is triggered, the compensation operations can be popped and executed sequentially in the reverse order of forward execution (i.e., reverse order of the DAG topological order), thus achieving correct chained compensation rollback.
[0148] The system adds a unique stack frame identifier, execution timestamp, and compensation dependency identifier to each stack frame of the chained compensation stack to enhance the traceability and management capabilities of compensation operations. The unique stack frame identifier is used to uniquely identify a specific compensation operation instance throughout the entire compensation lifecycle. The execution timestamp records the precise time when the preceding execution of the corresponding business step was successfully completed, which is crucial for auditing, performance analysis, and determining the relative order of compensation operations in complex scenarios. The compensation dependency identifier clarifies other compensation operations or their preceding execution context that the compensation operation depends on. This is particularly critical when handling business processes with complex dependencies or performing nested compensation rollbacks, helping to build a complete compensation chain.
[0149] In practical applications, when multiple branches of a chained business process execute in parallel, to avoid interference between compensation operations of different branches and to ensure the independence of their respective compensation logic, an independent chained compensation stack is maintained for each parallel branch. This means that when each branch executes its business steps successfully, it appends its reverse compensation operation to its independent compensation stack. When these parallel branches converge at a certain point in the process (e.g., the end of a parallel gateway), a merging operation needs to be performed on these independent chained compensation stacks. This merging operation specifically includes stack frame deduplication, conflict detection, and priority adjudication. Stack frame deduplication is used to identify and remove compensation operations that may be repeated in different parallel branches, ensuring that each actual compensation action is executed only once. Conflict detection aims to discover possible logical conflicts or resource competition between compensation operations of different branches, such as two branches attempting to roll back different states of the same shared resource. Priority adjudication, upon detecting a conflict, determines which compensation operation has a higher priority based on preset business rules or strategies, thereby guiding the compensation execution engine to perform the correct compensation processing.
[0150] This application's solution, by explicitly defining the push order of the chained compensation stack, ensures that compensation operations are strictly performed in reverse order of the DAG topology, thus resolving the problem of potentially chaotic compensation order in complex business processes. Through this technical solution, this application can ensure that the chained compensation stack accurately maintains the correct order of compensation operations under any business process structure, especially in complex processes containing parallel branches. This significantly improves the reliability and accuracy of compensation rollback, avoiding business data inconsistencies or system state chaos caused by incorrect compensation order. Furthermore, by attaching rich identification information to the stack frame, the manageability and traceability of compensation operations are greatly enhanced, providing detailed contextual information during fault diagnosis and auditing. Especially when handling parallel branches, the independent compensation stack and intelligent merging mechanism effectively resolve compensation conflicts and duplication issues in concurrent scenarios, ensuring the logical rigor and data integrity of the entire chained business process during rollback, thereby improving the overall robustness and business continuity of the system.
[0151] In some embodiments described above in this application, the chain-based business process management method proposes a compensation rollback mechanism. However, in practical applications, the execution of reverse compensation operations is not always successful on the first attempt or achieves the expected results, and may face problems such as resource unavailability, data inconsistency, or external service failures. If the reverse compensation operation is simply executed without detailed verification of the compensation execution results and an effective error handling mechanism, once the reverse compensation operation fails, the rollback of the entire chain-based business process may not be completely completed, resulting in inconsistent business data and even triggering more serious business risks.
[0152] In response, this application further proposes detailed steps for performing compensation execution verification on the execution result of each reverse compensation operation during the execution of the reverse compensation operation, and updating the stack state of the chained compensation stack or triggering nested compensation rollback based on the result of the compensation execution verification, so as to ensure the reliability and integrity of the compensation rollback.
[0153] Specifically, during the execution of the above reverse compensation operations, the steps of performing compensation execution verification on the execution result of each reverse compensation operation, and updating the stack state of the chained compensation stack or triggering nested compensation rollback based on the result of the compensation execution verification include:
[0154] Before each reverse compensation operation is executed, a compensation execution pre-check is performed to check the resource status required for compensation and the compensation execution status of dependent steps.
[0155] Execute the reverse compensation operation and collect the progress status and results of the compensation execution in real time;
[0156] The compensation execution result is subjected to a compensation execution verification, which includes at least one of compensation idempotency verification, compensation consistency verification, and compensation integrity verification.
[0157] When the compensation execution verification passes, the corresponding stack frame is popped from the chained compensation stack;
[0158] When the compensation execution verification fails, a nested compensation rollback is triggered from the corresponding stack frame of the chained compensation stack according to the predefined nested compensation rules. The nested compensation rollback includes recursively calling the compensation operation of the reverse compensation operation until the maximum nesting depth is reached or all compensation execution verifications pass.
[0159] Before executing the reverse compensation operation, a compensation execution pre-check is performed. This pre-check aims to ensure the compensation operation can proceed smoothly. Its main functions include checking the status of resources required for compensation, such as database connection status and the availability of external service interfaces, as well as checking the compensation execution status of dependent steps. This is to prevent the current compensation from failing due to the failure of the preceding compensation. For example, if a compensation operation requires access to an external system, the pre-check will confirm whether that external system is reachable and functioning correctly.
[0160] During the reverse compensation operation, the system collects the progress status and results of the compensation execution in real time. The progress status can include the current stage of the compensation operation, the percentage of completed subtasks, etc., while the compensation results record the final success or failure status of the operation, as well as any related error messages or output data. This real-time data is crucial for subsequent verification and troubleshooting.
[0161] Performing compensation execution verification on the compensation execution results is the core component of this solution. This verification can include at least one of the following: compensation idempotency verification, compensation consistency verification, and compensation integrity verification. Compensation idempotency verification ensures that even if the compensation operation is executed repeatedly, its impact on the system state is the same, without any side effects. Compensation consistency verification verifies whether the system data has been restored to a state consistent with that before the previous execution operation after the compensation operation; for example, checking whether the relevant account balances have been correctly rolled back. Compensation integrity verification ensures that the compensation operation covers all data and states that need to be rolled back without omission. These verification mechanisms collectively guarantee the correctness and reliability of the compensation operation.
[0162] When the compensation execution verification passes, it indicates that the reverse compensation operation has successfully and correctly completed its rollback task. At this time, the corresponding stack frame will be popped from the chained compensation stack, indicating that the compensation for this business step has been completed.
[0163] However, when compensation execution verification fails, the system does not simply terminate. Instead, it triggers a nested rollback from the corresponding stack frame of the chained compensation stack according to predefined nested compensation rules. Nested compensation rollback is a deeper error handling mechanism that involves recursively calling the compensation operation of the reverse compensation operation. This means that if a compensation operation itself fails, the system will attempt to execute a "compensation" operation for that operation to try to fix the problem caused by the compensation failure or roll back the impact of the compensation operation itself. This process continues until the preset maximum nesting depth is reached, or all compensation execution verifications pass, thereby ensuring the ultimate success of the compensation as much as possible.
[0164] The solution proposed in this application effectively solves the problem that the reverse compensation operation in the basic solution may fail for various reasons, resulting in incomplete rollback of business processes or data inconsistency. This is achieved by introducing a multi-layered compensation execution verification and a nested compensation rollback mechanism.
[0165] This application further proposes a scheme to mark the remaining uncompensated stack frames in the chained compensation stack as pending manual intervention when the aforementioned nested compensation rollback reaches the preset maximum nesting depth and there are still compensation execution verification failures.
[0166] Specifically, when the nested compensation rollback mechanism fails to successfully execute the reverse compensation operation after multiple attempts (reaching the preset maximum nesting depth), and the compensation execution verification results still show failures, the system will not simply give up or report an error. Instead, it will update the status of those stack frames in the chained compensation stack that failed to complete compensation (i.e., representing business steps that failed to be fully rolled back) to "awaiting manual intervention." "Maximum nesting depth" refers to the maximum number of recursive compensation operations allowed by the system, designed to prevent infinite loops or resource exhaustion. "Awaiting manual intervention" is a special marker indicating that the compensation processing of this business step requires manual intervention.
[0167] Furthermore, this application also proposes a scheme to generate a manual intervention work order and push the context information of the stack frame corresponding to the state awaiting manual intervention, the compensation dependency record, the compensation execution result, and the nested compensation history to the business operation and maintenance personnel.
[0168] The "Manual Intervention Work Order" is a structured task order used to guide business operations personnel in troubleshooting. When a stack frame is marked as requiring manual intervention, the system automatically generates a work order containing detailed information. This information includes, but is not limited to: the stack frame's "context information" (e.g., the current state of the business process, relevant business data), "compensation dependency records" (the original reverse compensation operation definition and its parameters), "compensation execution results" (detailed results of each compensation attempt, including the reasons for failure), and "nested compensation history" (a record of all nested compensation attempts). This information is pushed to the "business operations personnel," i.e., the professionals responsible for system operation, maintenance, and anomaly handling, so that they can fully understand the problem background and make diagnostic and decision-making decisions.
[0169] In addition, this application also proposes a scheme to receive processing instructions from business operation and maintenance personnel for the manual intervention work order, and to perform final compensation operations or mark it as an uncompensable anomaly according to the processing instructions.
[0170] "Processing instructions" refer to the specific operational instructions issued to the system by business operations personnel after analyzing work order information. These instructions may include: attempting to re-execute a compensation operation, manually modifying data to achieve the compensation effect, or confirming that a certain business step cannot be compensated automatically. After receiving these instructions, the system will execute the corresponding "final compensation operation" according to the instruction content, such as calling a specific API to correct data or executing a customized script. If business operations personnel determine that the compensation for a certain business step cannot be completed, or believe from a business perspective that no further compensation is necessary, they can mark it as "uncompensable exception," indicating that the compensation processing for that business step has been terminated and no further automated compensation attempts will be made.
[0171] This application's solution effectively addresses the issue that automated nested compensation rollback cannot completely resolve business process compensation failures under complex or extreme circumstances by introducing a manual intervention mechanism. Through this technical solution, this application further enhances the anomaly handling capabilities and system robustness of chained business processes based on existing nested compensation rollback mechanisms. Its unique technical advantage lies in providing a strategy that allows for a smooth transition to manual intervention when the automated compensation mechanism fails, avoiding business process interruptions or long-term data inconsistencies caused by compensation failure.
[0172] This application further proposes that the steps for updating the business step execution history database based on the execution result of the reverse compensation operation include:
[0173] For each business step, a structured execution record is generated, which includes the business step identifier, execution timestamp, execution result, compensation execution result, and final status.
[0174] The structured execution records are written into the business step execution history database in an immutable log format;
[0175] Based on the historical execution results in the business step execution history database, the success rate, average execution time, compensation trigger rate, and compensation success rate of each business step are statistically analyzed to obtain the statistical characteristics of business step execution.
[0176] The statistical characteristics of the business steps are fed back to the pre-execution inspection step and the chained compensation stack to optimize the dependency satisfaction threshold of the pre-execution inspection and the compensation triggering conditions of the chained compensation stack.
[0177] Specifically, structured execution records refer to a predefined data structure used to encapsulate key information during the execution of business steps. It includes a business step identifier to uniquely identify the executed business step; an execution timestamp to record the start or end time of the business step; an execution result indicating the success or failure of the forward execution operation; a compensation execution result indicating the success or failure of the reverse compensation operation; and a final state reflecting the final processing result of the business step in the entire process. The generation of these records aims to provide a comprehensive and easily analyzable snapshot of the execution process.
[0178] Immutable log formats can be understood as a data storage strategy that prevents modification or deletion once structured execution records are written to the business step execution history database. This format is typically implemented through append-only writing, ensuring the integrity, traceability, and tamper-proof nature of historical data. In practical applications, blockchain technology, content-addressed storage, or digital signatures can be used to guarantee log immutability, aiming to provide a reliable foundation for subsequent data analysis and auditing.
[0179] In practical applications, the statistical characteristics of business step execution are obtained by aggregating and calculating the structured execution records accumulated in the business step execution history database. For example, the success rate can be obtained by calculating the ratio of the number of successful executions of each business step within a specific time period to the total number of executions; the average execution time can be obtained by dividing the total time of all successfully executed operations by the number of successful executions; the compensation trigger rate can be obtained by calculating the ratio of the number of compensation triggers to the total number of executions; and the compensation success rate can be obtained by calculating the ratio of the number of successful compensations to the total number of compensations. These statistical characteristics aim to quantify the operational health of business steps and the effectiveness of the compensation mechanism.
[0180] Furthermore, the statistical characteristics of business step execution are fed back to the pre-execution inspection step and the chained compensation stack to achieve adaptive optimization of the system. For example, the pre-execution inspection step can dynamically adjust its dependency satisfaction threshold based on the historical success rate of a business step. For steps with a low success rate, stricter inspection conditions may be required. The chained compensation stack can adjust the compensation triggering conditions or compensation strategies based on the compensation triggering rate and compensation success rate. For example, for steps with a low compensation success rate, compensation may need to be triggered earlier or a more robust compensation scheme may need to be adopted.
[0181] This application's solution ensures the comprehensiveness, accuracy, and reliability of historical data on business step execution by introducing structured execution records and an immutable log format. It is precisely this high-quality historical data that makes it possible to accurately calculate key statistical characteristics such as the success rate, average execution time, compensation trigger rate, and compensation success rate of each business step. These statistical characteristics, as quantitative indicators, clearly reflect the operational health of the business steps and the effectiveness of the compensation mechanism. By feeding these statistical characteristics back in real time to the pre-execution inspection steps and the chained compensation stack, the system can learn and adjust itself based on actual operational data.
[0182] This application further proposes a scheme to identify deviations in the execution results after a business step is successfully executed, and to adjust the compensation priority or trigger an active rollback based on the identification results, so as to achieve early warning and intervention of potential risks, thereby improving the robustness and responsiveness of chain business processes.
[0183] After the forward execution operation of the current business step is successfully executed, the step of generating a compensation dependency record containing the reverse compensation operation further includes:
[0184] Deviation identification is performed on the execution result of the current business step, and the deviation identification includes anomaly deviation identification and performance deviation identification;
[0185] When an abnormal deviation or performance deviation is detected, the corresponding reverse compensation operation is marked as a high-priority compensation operation, and the priority of the corresponding stack frame in the chained compensation stack is adjusted.
[0186] When the abnormal deviation reaches the preset severity level, an active rollback command is triggered to perform preventative compensation rollback on the current business step and subsequent unexecuted business steps.
[0187] Specifically, deviation identification refers to analyzing the execution results of the forward operations of the current business step to determine whether they conform to expected behavior. This includes anomaly deviation identification and performance deviation identification. Anomaly deviation identification aims to detect whether there are any abnormalities in the execution results related to business logic or data integrity. For example, although the operation returns success, critical business data is not updated as expected, or the returned business status code, while indicating success, is accompanied by a warning message. Performance deviation identification focuses on the execution efficiency of business steps. For example, by comparing the current execution time with the historical average execution time or a preset performance baseline, it can determine whether there is a significant performance degradation. These identifications can be achieved through preset rules, machine learning models, or statistical analysis methods.
[0188] When the system detects abnormal deviations or performance deviations, to ensure timely handling before potential problems escalate, the corresponding reverse compensation operations are marked as high-priority compensation operations. Simultaneously, the priorities of stack frames related to this business step in the chained compensation stack are adjusted. This means that when subsequent compensation rollbacks are required, these high-priority compensation operations will be executed before other compensation operations, thereby accelerating the response to anomalies or performance issues.
[0189] Furthermore, when an anomaly reaches a preset severity level—for example, if the execution result of a critical business step deviates significantly from expectations, or if multiple minor deviations occur consecutively—the system will trigger a proactive rollback instruction. This proactive rollback instruction differs from a passive rollback triggered by execution failure or external instructions; it is a preventative measure. Once triggered, the system will perform a preventative compensatory rollback on the current business step and all subsequent unexecuted business steps. This means that even if the forward execution of the current business step appears successful, the system will proactively initiate a compensation process to avoid potentially greater risks due to a significant deviation in its result.
[0190] This application's solution introduces a deviation identification mechanism after successful execution of business steps, enabling real-time monitoring of the business process's health. When abnormal or performance deviations are identified, the system no longer passively waits for business failures but proactively prioritizes corresponding reverse compensation operations, or directly triggers preventative compensation rollbacks when deviations are severe. This mechanism allows the system to shift from "post-event remediation" to "pre-event warning and proactive intervention," thus intervening in problems at their initial stages and effectively preventing the escalation of potential risks. Dynamically adjusting the priority of compensation operations ensures that critical or abnormal compensations are executed first, improving the efficiency and targeting of compensation rollbacks.
[0191] refer to Figure 2 , Figure 2 This is a schematic diagram of a chain-based business process management system supporting compensation rollback provided in an embodiment of the present invention, used to implement the above method. The system includes:
[0192] The process modeling module is configured to build a DAG structure definition that includes business steps, prerequisites, forward execution operations, and reverse compensation operations based on the business process definition file.
[0193] The pre-inspection execution module communicates with the process modeling module and is configured to perform pre-inspection on the current business step based on the DAG structure definition and the execution status of the executed steps.
[0194] The business execution engine communicates with the pre-inspection execution module, is configured to activate the execution context and perform forward execution operations, and collects execution progress status and intermediate data snapshots in real time.
[0195] The chain compensation stack manager communicates with the business execution engine and is configured to maintain the reverse compensation operations of all successfully executed business steps in reverse order of DAG topology.
[0196] The compensation execution engine communicates with the chained compensation stack manager and is configured to execute reverse compensation operations sequentially from the top to the bottom of the chained compensation stack, and to perform compensation execution verification.
[0197] The nested compensation controller communicates with the compensation execution engine and is configured to trigger nested compensation rollback based on the result of compensation execution verification, and switch to manual intervention mode when the maximum nesting depth is reached.
[0198] The deviation identification and proactive rollback module communicates with the business execution engine and the chain compensation stack manager respectively, and is configured to perform deviation identification on the execution result and trigger proactive rollback instructions;
[0199] The execution history library module communicates with the business execution engine, the compensation execution engine, and the nested compensation controller, and is configured to persistently store structured execution records and maintain the statistical characteristics of business step execution.
[0200] The process modeling module, pre-inspection execution module, business execution engine, chain compensation stack manager, compensation execution engine, nested compensation controller, deviation identification and proactive rollback module, and execution history library module constitute a chain compensation rollback closed loop covering the entire process.
[0201] The chain-based business process management system supporting compensation rollback proposed in this application aims to effectively solve the problems of data inconsistency and compensation mechanism failure caused by deviations between internal logic and actual operation in traditional industrial internet systems when facing emergencies, through modular design and close collaboration. The system constructs a precise business process DAG structure through a process modeling module, performs pre-inspection execution module for risk identification, handles core business operations through a business execution engine, and achieves orderly compensation rollback through the chain-based compensation stack manager and compensation execution engine. A nested compensation controller handles complex scenarios of compensation failure, a deviation identification and proactive rollback module enhances the system's adaptability, and an execution history database module provides data support and feedback optimization. This forms an adaptive and self-correcting closed-loop management system, ensuring that chain-based business processes maintain high reliability and data consistency under various complex and dynamic environments.
[0202] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.
Claims
1. A chain-like business process management method supporting compensation rollback, characterized in that, include: Receive the steps to be executed in a chained business process, wherein the chained business process consists of multiple business steps with dependencies organized according to a directed acyclic graph (DAG) structure, and each business step defines a forward execution operation and a corresponding reverse compensation operation. Before executing the current business step, a pre-execution check is performed on the current business step based on the DAG structure and the execution status of the already executed steps, generating a pre-check result that includes dependency satisfaction status, resource readiness status, and the execution results of the preceding steps; In response to the pre-detection result being a successful pre-detection, the execution context of the current business step is activated, and the forward execution operation of the current business step is performed in the execution context; During execution, the execution progress status and intermediate data snapshots are collected in real time. When the forward execution operation of the current business step is successfully executed, a compensation dependency record containing the reverse compensation operation is generated, and the compensation dependency record is appended to the chained compensation stack; the chained compensation stack maintains the reverse compensation operations of all successfully executed business steps in reverse order of the DAG topology. When the forward execution operation of the current business step fails or the chained business process triggers a rollback instruction, the reverse compensation operation of each successfully executed business step is executed in sequence from top to bottom of the chained compensation stack to achieve chained compensation rollback. During the execution of the reverse compensation operation, a compensation execution verification is performed on the execution result of each reverse compensation operation, and the stack state of the chained compensation stack is updated or a nested compensation rollback is triggered based on the result of the compensation execution verification. Based on the execution result of the reverse compensation operation, the business step execution history database is updated, and the updated business step execution history database is fed back to the pre-execution inspection step and the chain compensation stack, forming a chain compensation rollback closed loop covering the entire process.
2. The method according to claim 1, characterized in that, The chained business process consists of multiple dependent business steps organized according to a directed acyclic graph (DAG) structure, including the following steps: Based on the business process definition file, the chained business process is parsed using BPMN 2.0 or the Workflow Network WfMC standard to obtain a flowchart containing a set of nodes, a set of directed edges, and node attributes. Perform topological sorting on the flowchart to generate a DAG topological sequence of the chained business process; in the DAG topological sequence, the prerequisite dependent steps of each business step are all located before the corresponding business step; Define the input parameter contract and output parameter contract for the forward execution operation and the compensation input parameter contract and compensation output parameter contract for the corresponding reverse compensation operation for each business step in the DAG topology sequence; Based on the input parameter contract, the output parameter contract, the compensation input parameter contract, and the compensation output parameter contract, construct the DAG structure definition of the chained business process.
3. The method according to claim 1, characterized in that, The step of performing a pre-execution check on the current business step before execution, based on the DAG structure and the execution status of already executed steps, includes: Based on the DAG structure, determine all the preceding dependent steps of the current business step; Retrieve the latest execution status and result data of all the preceding dependent steps from the business step execution history database; Based on the latest execution status and the execution result data, verify whether all the prerequisite dependency steps have been executed successfully. Obtain the resource status required for the execution of the current business step, including database connection status, lock resource status, and external service availability status; Based on the execution status of all the preceding dependent steps and the resource status, a pre-detection result is generated, which includes the dependency satisfaction status, resource readiness status, and the execution results of the preceding steps.
4. The method according to claim 1, characterized in that, The step of generating a compensation dependency record containing the reverse compensation operation when the forward execution operation of the current business step is successful includes: At the moment when the forward execution operation of the current business step is successfully executed, capture a snapshot of the input parameters, a snapshot of the output parameters, and the execution context identifier of the current business step; Based on the DAG node definition of the current business step, find the corresponding reverse compensation operation definition; According to the compensation input parameter contract of the reverse compensation operation, the compensation input parameters are extracted from the input parameter snapshot and the output parameter snapshot; The compensation input parameters, the reverse compensation operation definition, the execution context identifier, and the capture timestamp are encapsulated into a compensation dependency record; The compensation dependency record is appended to the chained compensation stack.
5. The method according to claim 1, characterized in that, The chain-like compensation stack maintains the reverse compensation operations for all successfully executed business steps in reverse order of the DAG topology, including the following steps: The chain compensation stack is constructed in reverse order of the DAG topology to ensure that the reverse compensation operation of the later executed business step is at the top of the stack and the reverse compensation operation of the earlier executed business step is at the bottom of the stack. Each stack frame of the chained compensation stack is appended with a unique stack frame identifier, an execution timestamp, and a compensation dependency identifier; When multiple branches of the chained business process are executed in parallel, an independent chained compensation stack is maintained for each branch, and a merging operation of the chained compensation stack is performed at the branch merging point; the merging operation includes stack frame deduplication, conflict detection, and priority adjudication.
6. The method according to claim 1, characterized in that, The steps of performing compensation execution verification on the execution result of each reverse compensation operation during the execution of the reverse compensation operation, and updating the stack state of the chained compensation stack or triggering nested compensation rollback based on the result of the compensation execution verification include: Before each reverse compensation operation is executed, a compensation execution pre-check is performed to check the resource status required for compensation and the compensation execution status of dependent steps. Perform the reverse compensation operation and collect the progress status and results of the compensation execution in real time; The compensation execution result is subjected to a compensation execution verification, which includes at least one of compensation idempotency verification, compensation consistency verification, and compensation integrity verification. When the compensation execution verification passes, the corresponding stack frame is popped from the chained compensation stack; When the compensation execution verification fails, a nested compensation rollback is triggered from the corresponding stack frame of the chained compensation stack according to the predefined nested compensation rules. The nested compensation rollback includes recursively calling the compensation operation of the reverse compensation operation until the maximum nesting depth is reached or all compensation execution verifications pass.
7. The method according to claim 6, characterized in that, After the step of triggering a nested compensation rollback from the corresponding stack frame of the chained compensation stack according to the predefined nested compensation rules when the compensation execution verification fails, the method further includes: When the nested compensation rollback reaches the preset maximum nesting depth and there are still compensation execution verification failures, the remaining uncompensated stack frames in the chained compensation stack are marked as awaiting manual intervention. Generate a manual intervention work order and push the context information, compensation dependency record, compensation execution result and nested compensation history of the stack frame corresponding to the state requiring manual intervention to the business operation and maintenance personnel. Receive processing instructions from business operations and maintenance personnel for the manual intervention work order, and perform final compensation operations or mark it as an uncompensable anomaly according to the processing instructions.
8. The method according to claim 1, characterized in that, The step of updating the business step execution history database based on the execution result of the reverse compensation operation includes: For each business step, a structured execution record is generated, which includes the business step identifier, execution timestamp, execution result, compensation execution result, and final status. The structured execution records are written into the business step execution history database in an immutable log format; Based on the historical execution results in the business step execution history database, the success rate, average execution time, compensation trigger rate, and compensation success rate of each business step are statistically analyzed to obtain the statistical characteristics of business step execution. The statistical characteristics of the business steps are fed back to the pre-execution inspection step and the chained compensation stack to optimize the dependency satisfaction threshold of the pre-execution inspection and the compensation triggering conditions of the chained compensation stack.
9. The method according to claim 1, characterized in that, After the step of generating a compensation dependency record containing the reverse compensation operation when the forward execution operation of the current business step is successfully executed, the method further includes: Deviation identification is performed on the execution result of the current business step, and the deviation identification includes anomaly deviation identification and performance deviation identification; When an abnormal deviation or performance deviation is detected, the corresponding reverse compensation operation is marked as a high-priority compensation operation, and the priority of the corresponding stack frame in the chained compensation stack is adjusted. When the abnormal deviation reaches the preset severity level, an active rollback command is triggered to perform preventative compensation rollback on the current business step and subsequent unexecuted business steps.
10. A chain-like business process management system supporting compensation rollback, used to implement the method of any one of claims 1 to 9, characterized in that, The system includes: The process modeling module is configured to build a DAG structure definition that includes business steps, prerequisites, forward execution operations, and reverse compensation operations based on the business process definition file. The pre-inspection execution module is communicatively connected to the process modeling module and is configured to perform a pre-inspection on the current business step based on the DAG structure definition and the execution status of the executed steps. The business execution engine communicates with the pre-inspection execution module and is configured to activate the execution context and perform forward execution operations, and collect execution progress status and intermediate data snapshots in real time. The chain compensation stack manager is connected to the business execution engine and is configured to maintain the reverse compensation operation of all successfully executed business steps in reverse order of DAG topology. The compensation execution engine is communicatively connected to the chained compensation stack manager and is configured to perform reverse compensation operations sequentially from the top to the bottom of the chained compensation stack, and to perform compensation execution verification. The nested compensation controller is communicatively connected to the compensation execution engine and is configured to trigger nested compensation rollback based on the result of compensation execution verification, and switch to manual intervention mode when the maximum nesting depth is reached. The deviation identification and active rollback module is communicatively connected to the business execution engine and the chain compensation stack manager, respectively, and is configured to perform deviation identification on the execution result and trigger an active rollback instruction; The execution history library module is communicatively connected to the business execution engine, the compensation execution engine, and the nested compensation controller, and is configured to persistently store structured execution records and maintain statistical characteristics of business step execution. The process modeling module, the pre-inspection execution module, the business execution engine, the chain compensation stack manager, the compensation execution engine, the nested compensation controller, the deviation identification and active rollback module, and the execution history library module constitute a chain compensation rollback closed loop covering the entire process.