A method and device for realizing node fallback function
By receiving and processing process fallback requests, traversing the process tracking diagram and executing the fallback steps, the problem of diversity of backback requirements in complex processes is solved, flexible path adjustment and accurate fallback operations are achieved, and process management is improved. Accuracy and user experience.
Patent Information
- Application Number
- CN202411230344.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-04
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2044-09-04
AI Technical Summary
The prior art is difficult to cope with the diverse fallback requirements in complex processes, such as insufficient identification of automatic submission nodes, confusing continuous fallback logic and lack of reverse fallback functions, resulting in limited process management accuracy and user experience.
By receiving the fallback request initiated by the user or the system, read the process tracking diagram of the process instance, traverse and execute the corresponding fallback steps, including recursively traversing the subprocesses under special nodes, summarizing the fallback nodes, selecting the fallback strategy and Use the process engine interface to activate the target fallback node, update the process status and tracking diagram.
It realizes flexible adjustment of execution paths in complex business processes, improves the dynamics of business logic and user satisfaction, ensures the correctness and effectiveness of fallback operations, and supports more complex and diverse business process requirements.
Smart Images

Figure CN118735245B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of information processing technology, and in particular to a method and device for implementing a node fallback function. Background Art
[0002] In the field of modern business process management and automation, workflow engines play a vital role. As a popular workflow and business process management platform, Activiti provides enterprises with powerful process definition, execution and monitoring capabilities. However, although Activiti is feature-rich in process management, its native design does not directly support process rollback, which is a common and important requirement in many complex business processes.
[0003] In order to make up for the defect that Activiti does not natively support the rollback function, the existing technology usually adopts a process history-based approach to implement node rollback.
[0004] However, existing technologies are difficult to cope with the diverse rollback requirements in complex processes. For example, there are insufficient automatic submission node recognition, confusing continuous rollback logic, and a lack of reverse rollback function. The rollback process is less flexible, which limits the accuracy of process management and user experience. Summary of the invention
[0005] In an embodiment of the present application, by providing a method for implementing a node fallback function, the problem that the prior art is difficult to cope with the diversity of fallback requirements for complex processes is solved.
[0006] In a first aspect, an embodiment of the present application provides a method for implementing a node rollback function, the method comprising: receiving a rollback request initiated by a user or a system; reading the current process tracking graph from the variables of the process instance; starting from the current node, traversing the process tracking graph forward; executing corresponding rollback steps according to the node categories encountered in the process of traversing the process tracking graph; when encountering a special node in the process of traversing the process tracking graph, executing a first rollback step; the special node includes an inclusive gateway node, a branch node, and a merge node; when encountering an ordinary node in the process of traversing the process tracking graph, executing a second rollback step Step; when encountering a special node in the process of traversing the process tracking graph, executing the first fallback step, including: recursively traversing all sub-process tracking graphs under the special node; summarizing all nodes with fallback node types to form a fallback node set; selecting a fallback strategy, and selecting a node from the fallback node set as the target fallback node; wherein the fallback strategy includes: fallback to the predecessor node, fallback to the source node, and fallback to the start node; using the interface provided by the process engine to activate the selected target fallback node; updating the state of the process instance and the process tracking graph to complete the first fallback step.
[0007] In a possible implementation, before receiving a rollback request initiated by a user or system, it includes: creating a process instance according to a preset process definition and initializing its state; executing each node in the process one by one according to the sequence or conditional logic in the process definition; during the execution of each node, updating the state of the process instance and the process tracking diagram; wherein the process tracking diagram records all execution paths and state changes of the process instance from the beginning to the present.
[0008] In a possible implementation, during the execution of each node, the status of the process instance and the process tracking diagram are updated, including: when the node is a special node, the corresponding operation is performed according to the type and execution logic of the special node, and after the execution is completed, the process tracking diagram and the status of the process instance are updated according to the execution result; when the node is an ordinary node, the defined operation is directly executed, and after the execution is completed, the process tracking diagram and the status of the process instance are updated.
[0009] In a possible implementation, the updating of the process instance status and process tracking diagram during the execution of each node also includes: during the node execution, if the process needs to wait for an external event, pausing the execution of the current node, and setting a listening mechanism to wait for and respond to the corresponding event.
[0010] In one possible implementation, when a common node is encountered during the traversal of the process tracking graph, a second backoff step is performed, including: determining whether the common node currently traversed meets the backoff condition; if the common node does not meet the backoff condition, ignoring the common node and continuing to traverse the process tracking graph forward; if the common node meets the backoff condition, performing the backoff operation from the common node, and after the execution is completed, updating the status of the process tracking graph and the process instance, and determining whether the common node is the target backoff node; if the common node is the target backoff node, the backoff operation is completed, and the traversal of the process tracking graph ends; if the common node is not the target backoff node, continuing to traverse the process tracking graph forward until the target backoff node is found.
[0011] In a possible implementation, the fallback condition is: the common node is a predecessor node of a target fallback node, and the node type of the common node is a fallback node type.
[0012] In the second aspect, an embodiment of the present application provides a device for implementing a node rollback function, the device comprising: a receiving module for receiving a rollback request initiated by a user or a system; a reading module for reading the current process tracking graph from the variables of the process instance; a traversal module for traversing the process tracking graph forward starting from the current node; a conditional rollback module for executing corresponding rollback steps according to the node category encountered in the process of traversing the process tracking graph; a first rollback step execution module for executing the first rollback step when a special node is encountered in the process of traversing the process tracking graph; the special node comprises an inclusive gateway node, a branch node and a merge node; the when in the process of traversing the process tracking graph When a special node is encountered, a first fallback step is executed, including: recursively traversing all sub-process tracking graphs under the special node; summarizing all nodes whose node types are fallback node types to form a fallback node set; selecting a fallback strategy, and selecting a node from the fallback node set as a target fallback node; wherein the fallback strategy includes: fallback to the predecessor node, fallback to the source node, and fallback to the start node; using the interface provided by the process engine to activate the selected target fallback node; updating the state of the process instance and the process tracking graph to complete the first fallback step; executing the second fallback step module, which is used to execute the second fallback step when a normal node is encountered during the traversal of the process tracking graph.
[0013] In the third aspect, an embodiment of the present application provides a server for implementing a node fallback function, comprising a memory and a processor; the memory is used to store computer-executable instructions; the processor is used to execute the computer-executable instructions to implement the method described in the first aspect or any possible implementation method of the first aspect.
[0014] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores executable instructions, and when a computer executes the executable instructions, the method described in the first aspect or any possible implementation method of the first aspect can be implemented.
[0015] One or more technical solutions provided in the embodiments of the present application have at least the following technical effects:
[0016] The embodiment of the present application provides a method for implementing a node fallback function. By receiving a fallback request initiated by a user or a system, the process allows the execution path to be flexibly adjusted in a complex business process. This flexibility allows the business logic to adapt to changes in actual conditions more dynamically and reduce business obstacles caused by fixed processes. Users can choose the node to fall back to according to actual needs, thereby more accurately controlling the direction of the business process. This personalized operation method improves user satisfaction and participation, making the business process closer to the actual needs of users. Through process tracking diagrams and node category processing (special nodes and ordinary nodes), the system can more clearly understand the structure and status of the business process. Not only does it simplify the maintenance and management of the process, but it also enables faster location and resolution of problems when problems arise. For the complex logic processes of special nodes, the fallback process can accurately identify and process these special nodes to ensure the correctness and effectiveness of the fallback operation. This enables the system to support more complex and diverse business process requirements. Through the call of the fallback strategy and the process engine interface, the automatic processing of the fallback operation is realized. The problem that the existing technology is difficult to cope with the diversity of fallback requirements for complex processes is solved. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments of the present application or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0018] Figure 1 A flowchart of a method for implementing a node fallback function provided in an embodiment of the present application;
[0019] Figure 2 A specific flow chart before receiving a rollback request initiated by a user or system provided in an embodiment of the present application;
[0020] Figure 3 A specific flow chart for updating the state of a process instance and a process tracking diagram during the execution of each node provided in an embodiment of the present application;
[0021] Figure 4 A specific flow chart for executing a first fallback step when encountering a special node in the process of traversing a process tracking graph provided in an embodiment of the present application;
[0022] Figure 5 A specific flow chart of executing the second fallback step when encountering a common node in the process of traversing the process tracking graph provided by the embodiment of the present application;
[0023] Figure 6 A flowchart of a simple process definition provided in an embodiment of the present application;
[0024] Figure 7 The basis provided for the embodiments of this application Figure 6 A first process tracking diagram constructed by the flowchart in;
[0025] Figure 8 Provided in the embodiments of this application Figure 7 When the first process tracking diagram in runs to the approval task node, the second process tracking diagram constructed;
[0026] Fig. 9 A flow chart including an inclusive gateway node provided for an embodiment of the present application;
[0027] Fig.10 For the embodiment of the present application provided Fig. 9 The third process tracking diagram constructed after the process is initiated and the form filling node completes the form filling;
[0028] Fig.11 For the embodiment of the present application provided Fig. 9 The fourth process tracking diagram constructed when the two tasks of approval 1 and approval 2 are executed through the inclusive gateway to the approval 3 node is submitted respectively;
[0029] Fig.12 For the application example provided Fig.11 The fifth process tracking diagram constructed when the approval 1 node and the approval 2 node are activated;
[0030] Fig.13 A schematic diagram of a device for implementing the node fallback function provided in an embodiment of the present application;
[0031] Fig.14 A schematic diagram of a server implementing the node fallback function provided in an embodiment of the present application. DETAILED DESCRIPTION
[0032] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0033] The following describes some of the techniques involved in the embodiments of the present application to facilitate understanding, and they should be considered as merely exemplary. Therefore, it should be appreciated by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present application. Similarly, for the sake of clarity and conciseness, some descriptions of well-known functions and structures are omitted in the following description.
[0034] In the existing workflow engine market, although mainstream frameworks such as Activiti provide powerful process management capabilities for enterprise-level applications, they do not directly support the rollback function of process nodes. In order to solve this demand, other products usually use a method based on process history records to implement node rollback. The rollback process of these products is as follows: First, after the rollback operation is triggered, the system will look for historical submission data to locate the execution track of the process; then, identify and locate the target rollback node in the process history, that is, the node that needs to be rolled back; then, try to restore or reset the process state to the node by activating the node; some products even try to modify the BPM diagram (business process diagram) at runtime to temporarily modify the post-logic of the current node to point to the target rollback node, thereby forcing the process to roll back to the previous node. However, this method is prone to cause problems in a high-concurrency environment, because directly modifying the BPM diagram will cause other normally running process instances to become confused.
[0035] Existing technologies mainly rely on process history data to implement node rollback. This method may be sufficient when dealing with regular processes, but it seems to be inadequate when facing more complex and special process operation situations. Specifically, it is difficult or impossible to effectively deal with the following special situations: 1. Automatic submission node. Existing technologies usually rely only on the historical records of the process to track the execution status of the node, but the historical records often do not contain enough information to distinguish whether a node is normally approved by the user or automatically submitted. Therefore, when rollback is required, the system cannot accurately identify which nodes are automatically submitted, and thus cannot make appropriate rollback decisions. According to the design of other products, when rollback is required, the system may simply activate the most recently executed node without considering whether the node is automatically submitted. This rollback logic is particularly unreasonable when dealing with processes containing automatic submission nodes, because it may cause the process to roll back to a node that is not actually operated by the user. Due to the inability to accurately identify and process automatic submission nodes, existing technologies may undermine the consistency and accuracy of the process when performing rollbacks. For example, before rolling back to a certain auto-commit node, it may be necessary to process the preconditions or logic associated with the node first, and existing technologies often cannot automatically complete these tasks. 2. Convergence of inclusive gateways. The converging feature of inclusive gateways allows multiple original process paths to converge into one at the converging point. However, existing technologies usually only rely on the historical submission data of the process to track the execution status of the node, which makes it difficult to accurately identify the independent branch nodes before the converging when rolling back. Since the node after the converging of the inclusive gateway actually represents a collection of multiple predecessor nodes, when executing the rollback, these predecessor nodes need to be activated at the same time to restore the process to the state before the converging. This complex rollback logic is very difficult to implement for technologies that only rely on process history records. 3. Continuous rollback. Existing technologies usually search for the target node for rollback from the process submission history in reverse chronological order. However, in the case of continuous rollback, this method cannot accurately distinguish whether it is rolling back forward (i.e. activating the predecessor node) or rolling back backward (i.e. undoing the executed operation). In particular, when the rollback operation itself is also recorded in the process history, the system may mistakenly regard the rollback operation as the target of the rollback, resulting in confusion in the rollback logic. 4. Reverse rollback. Existing technologies usually only support a simple rollback strategy to the previous node, but cannot provide user-defined rollback options, such as rolling back to the source node or the starting node. This single rollback strategy cannot meet the diverse rollback needs of users, limiting the flexibility of process management and user experience.
[0036] In summary, the existing technology has obvious limitations in handling process node rollback, especially when dealing with complex and special process operation situations, its shortcomings are particularly prominent.
[0037] The present application embodiment provides a method for implementing a node fallback function, such as Figure 1 As shown, the method includes steps S101 to S106. Among them, Figure 1 This is only an execution order shown in the embodiment of the present application, and does not represent the only execution order of a method for implementing the node rollback function. If the final result can be achieved, Figure 1 The steps shown may be performed in parallel or reversed.
[0038] S101: receiving a rollback request initiated by a user or a system.
[0039] Specifically, the core content of the rollback request is the target rollback node information, that is, the target node information to be rolled back to. This includes the node's unique identifier (such as ID), name or type, etc., so that the system can accurately identify and locate the node. In addition to the target rollback node information, the rollback request can also contain other additional information, such as the rollback reason, user comments, identifiers of related data, etc. This information helps the system record the history of the rollback operation.
[0040] Figure 2 A specific flow chart before receiving a rollback request initiated by a user or system provided in an embodiment of the present application, such as Figure 2 As shown, it includes steps S201 to S203.
[0041] S201: Create a process instance according to the preset process definition and initialize its state.
[0042] Specifically, the preset process definition contains key information such as the structure of the process, node types, execution order, and conditional logic. When a process instance is created, the system assigns it a unique identifier and initializes its state. The initial state usually means that the process has not yet started execution and all nodes are in a pending or inactive state.
[0043] S202: Execute each node in the process one by one according to the sequence or conditional logic in the process definition.
[0044] Specifically, after the process instance is created and initialized, the system will execute each node in the process one by one according to the order or conditional logic specified in the process definition. These nodes may include start events, task nodes (such as approval nodes, form filling nodes, etc.), gateway nodes, and end events.
[0045] S203: During the execution of each node, the state of the process instance and the process tracking diagram are updated, wherein the process tracking diagram records all execution paths and state changes of the process instance from the beginning to the present.
[0046] Specifically, the status of a process instance reflects the progress and results of the current process execution, such as which nodes have been completed, which nodes are being executed, and which nodes have not yet started.
[0047] Furthermore, the process tracking diagram is a dynamic data structure used to record the running status of the process in real time, including the currently activated node, the last passed node, and the historical path of the process. Unlike the BPMN flowchart (a static definition diagram), the process tracking diagram can reflect the actual situation of the process at runtime. The process tracking diagram is built based on a linked list data structure. Each node implements the TraceNode interface and can include event nodes (such as start and end nodes), connection line nodes (SequenceFlowNode), and task nodes, such as ordinary task nodes (TaskNode), multi-instance task nodes (MultiInstanceTaskNode), and diverted nodes (DivertedNode). These nodes are connected in a clear direction to form a directed graph structure, which describes the execution path of the process. The tail pointer of the linked list always points to the currently activated node.
[0048] Figure 6 A flowchart of a simple process definition provided in an embodiment of the present application, such as Figure 6 As shown, Figure 6 The flowchart in can be expressed in words as: start → fill in the form → approve → end. In the above simple process, there are two start and end nodes, three connecting lines and two task nodes. The final step from the beginning to the end of the process is: initiate the process, and the process enters the start node. This step is the starting point of the process. When an event or operation is triggered (such as the user clicks the "Start" button), the process is started and enters the start node. The start node is usually a non-operational node used to mark the beginning of the process. The process automatically leaves the start node and flows to the fill in the form node through line 1. The process enters the fill in the form node. After the user fills in the data, the process leaves the fill in the form node and continues to flow to the approval node through line 2. At the fill in the form node, the user needs to perform some input operations, such as filling in the form, uploading files, etc. The process enters the approval node. After the approver performs the approval operation, it leaves the approval node and continues to flow to the end node through line 3. At the approval node, the designated approver needs to review the data submitted by the fill in the form node and make a decision to approve or reject. Once the approver completes the approval operation (whether it is approval or rejection), the process will leave the approval node and continue to flow to the end node along line 3. Entering the end node, the process automatically integrates data, and leaving the end node, the process ends. The end node is the end point of the process. Before reaching the end node, the process has gone through a series of operations and decisions. At the end node, the system may perform some cleanup work, such as integrating data, sending notifications, etc. After completing these operations, the process will leave the end node and officially end.
[0049] Further, from Figure 6In the process shown, each node (such as "start", "fill in a form", "approval" and "end") is accompanied by two events: entry and exit. These events are key trigger points in the process execution process, which are used to control the flow of the process and update the process tracking diagram. When the process executes to the entry event of a node, the process tracking diagram will perform corresponding operations to record this state. The following is a detailed description of this process: 1. Query the process variables under the current process execution identifier (execution id). When the process is executed, each execution instance will have a unique execution identifier (execution id). Through this identifier, the system can query and obtain all process variables of the current process instance (execution). These variables contain the state information of the process, including the existing process tracking diagram. 2. Parse the current execution process tracking diagram from the process variables. If the process has been executed for a period of time, the process variables may already contain the current process tracking diagram. The system needs to parse these variables and extract the current state of the process tracking diagram. 3. Read the current node information and build the process task node. When the process enters the entry event of a certain node (such as the approval task node), the system needs to read the detailed information of the node, including the node type, name, executor, etc. Then, a new process task node (such as TaskNode) is constructed based on this information to represent the current node in the process tracking diagram. 4. Append the data of the current node to the tail pointer of the process tracking diagram linked list. The process tracking diagram is usually stored in the form of a linked list, in which each node contains pointers to the previous node and the next node (or only contains a pointer to the next node). In this step, the newly constructed process task node is added to the end of the linked list by modifying the tail pointer. In this way, the process tracking diagram records the latest status of the process. 5. Store the updated process tracking diagram in the currently executed variable. After completing the appending of the node data, the updated process tracking diagram needs to be stored back in the process variable so that it can be used in the subsequent execution of the process. In this way, no matter when and where the process is executed, the latest process tracking diagram can be obtained by querying the process variable. 6. Complete the additional logic of the process tracking diagram. In addition to the basic node appending operation, other additional logic may be implemented in the process tracking diagram according to specific needs, such as node status update, exception handling, logging, etc. These logics can be customized and extended according to actual business needs.
[0050] Figure 7 The basis provided for the embodiments of this application Figure 6 The first process tracking diagram constructed by the flowchart in Figure 7 As shown, Figure 7The first process tracking diagram in the figure can be expressed in words as: start event node → line 1 → form filling task node → line 2 → approval task node → line 3 → end event node. Among them, the start event node is the head node of the linked list, and the end event node is the tail node of the linked list. Figure 7 The first process tracking diagram records the entire status of the process running.
[0051] Figure 8 Provided in the embodiments of this application Figure 7 When the first process tracking diagram in runs to the approval task node, the second process tracking diagram constructed is as follows: Figure 8 As shown, Figure 8 The second process tracking diagram in can be expressed in words as: start event node → line 1 → form filling task node → line 2 → approval task node. Among them, the start event node is the head node of the linked list, and the approval task node is the tail node of the linked list. Compared with the first process tracking diagram, the second process tracking diagram only records part of the state of the process from the beginning to the approval task node.
[0052] Specifically, in the second process tracking diagram, if you want to roll back to the form filling task node, the system can traverse the linked list structure of the process tracking diagram from the current tail node (approval task node) forward until the form filling task node is found. This rollback function is implemented based on the real-time and dynamic nature of the process tracking diagram, making process management more flexible and efficient.
[0053] Figure 3 The specific flow chart of updating the state of the process instance and the process tracking diagram during the execution of each node provided by the embodiment of the present application is as follows: Figure 3 As shown, it includes steps S301 to S303.
[0054] S301: When the node is a special node, a corresponding operation is performed according to the type and execution logic of the special node. After the execution is completed, the process tracking diagram and the status of the process instance are updated according to the execution result.
[0055] S302: When the node is a common node, directly execute its defined operation, and after the execution is completed, update the status of the process tracking diagram and the process instance.
[0056] S303: During the node execution process, if the process needs to wait for an external event, the execution of the current node is suspended, and a monitoring mechanism is set to wait for and respond to the corresponding event.
[0057] Specifically, in some cases, the execution of a node may need to wait for external events to occur, such as user input, third-party system response, etc. At this time, the system needs to suspend the execution of the current node and set up a monitoring mechanism to wait for and respond to the corresponding event. When the system detects that the execution of a node needs to wait for an external event, the execution of the node is immediately suspended. Set up a monitoring mechanism, such as monitoring a message queue, so that it can respond in time when an external event occurs. Once the occurrence of an external event is monitored, the system immediately resumes the execution of the node and continues the subsequent process. During the waiting and resuming execution process, the system will also update the status of the process tracking diagram and the process instance to reflect the current waiting status and the resumption of execution.
[0058] S102: Read the current process tracking diagram from the variables of the process instance.
[0059] Specifically, a process instance is previously created based on a preset process definition, and its status and variables are continuously updated during execution.
[0060] The purpose of step S102 is to obtain complete tracking information of the process instance during execution, including executed nodes, execution order, branch selection, etc. This is important for understanding the execution path of the process, diagnosing problems, optimizing the process, and auditing and compliance checks. By reading the current process tracking diagram, the system or user can more clearly understand the current status and historical changes of the process, so as to make more accurate decisions and actions.
[0061] S103: Starting from the current node, traverse the process tracking graph forward.
[0062] Specifically, the process tracking graph can be regarded as a linear structure that records the execution order of nodes, and the current node can be regarded as the last element in this linear structure, that is, the position pointed to by the tail pointer. Traversing forward from the current node means backtracking the execution history of the process.
[0063] S104: Execute corresponding fallback steps according to the node categories encountered in the process of traversing the process tracking graph, wherein the node categories are special nodes and ordinary nodes.
[0064] S105: When encountering a special node during the traversal of the process tracking graph, executing the first fallback step. The special nodes include inclusive gateway nodes, branch nodes, and merge nodes.
[0065] Figure 4 A specific flowchart of executing the first fallback step when encountering a special node in the process of traversing the process tracking graph provided by the embodiment of the present application, such as Figure 4 As shown, it includes steps S401 to S405.
[0066] S401: recursively traverse all sub-process tracking graphs under a special node.
[0067] Specifically, when encountering special nodes in the process of traversing the process tracking graph, since these nodes contain multiple branches or sub-processes, it is necessary to recursively traverse all sub-process tracking graphs under these special nodes.
[0068] S402: Aggregate all nodes whose node types are fallback node types to form a fallback node set.
[0069] Specifically, this step provides comprehensive data support for the subsequent selection of fallback strategies, ensuring that all possible options are considered when making decisions.
[0070] S403: Select a fallback strategy, and select a node from the fallback node set as a target fallback node. The fallback strategies include: fallback to a previous node, fallback to a source node, and fallback to a start node.
[0071] Specifically, the fallback strategy in the present application is a preset fallback strategy.
[0072] S404: Activate the selected target rollback node using the interface provided by the process engine.
[0073] Specifically, by calling the interface provided by the process engine, the selected target fallback node is marked as activated. The planContinueProcessOperation method of the Activiti engine used in this application is to activate the selected target fallback node. The planContinueProcessOperation method is a built-in method of the Activiti engine, which belongs to the ActivitiEngineAgenda interface, a scheduling-based component of the Activiti engine. The ActivitiEngineAgenda interface encapsulates the logic used to schedule and manage process execution tasks within the Activiti engine. Whenever a node needs to fall back, determine the target fallback node, and then obtain the entity executionEntity of the current process instance (execution) through the data query interface. ExecutionEntity is a specific implementation class of the process instance (execution), which provides more internal operation capabilities, allowing developers or internal mechanisms of the engine to directly access and modify the underlying data of the process instance. You can change the currentFlowElement field of the entity (an internal attribute of the entity executionEntity) to point it to the target fallback node, and then call the Context.getAgenda().planContinueProcessOperation(executionEntity) method to finally implement the fallback logic of a process. This method plans or arranges an operation to continue the execution of the process based on the specified execution entity (executionEntity), which is used to implement custom fallback logic or change the execution path during the process execution.
[0074] S405: Update the state of the process instance and the process tracking diagram to complete the first rollback step.
[0075] Specifically, rolling back to the predecessor node is the most common rollback strategy, which follows the natural order of nodes in the BPMN flowchart to ensure that the rollback operation will not roll back to the node after the current node in the BPMN flowchart. The path from the current node to the beginning of the process is traversed, and each predecessor node is found and verified to determine which node is the appropriate rollback target. The verification process may include checking the node type (such as whether it is a rollback node type), the dependencies between nodes, etc. Finally, a qualified predecessor node is selected as the target rollback node. When rolling back to the source node (or a specific node), the default predecessor node verification logic is not followed, but the specified source node is directly rolled back. This strategy is usually based on business rules or the needs of specific scenarios, allowing intermediate steps to be skipped and directly rolled back to a key node in the process. When this strategy is selected, the above verification logic for the predecessor node will be skipped, and the system will directly locate and activate the specified source node. Rolling back to the start node is the simplest rollback strategy, which rolls the process back to the start node, that is, the head pointer node of the process tracking diagram (such as the start event). Under this strategy, there is no need for complex node verification or traversal, and the head pointer node is directly read and activated.
[0076] Fig. 9 The flowchart provided for the embodiment of the present application includes an inclusive gateway node, such as Fig. 9 As shown in the figure, the start event triggers the process. The form filling node is the node where the user needs to fill in information. The inclusive gateway is used to flow to multiple branches at the same time according to conditions. Line 1 is the connection line between the start event and the form filling node. Line 2 and Line 3 are two lines that flow out from the form filling node according to conditions, connected to the approval 1 node and the approval 2 node respectively.
[0077] Fig.10 For the embodiment of the present application provided Fig. 9 The third process tracking diagram constructed after the process is initiated and the form filling node completes the form filling, such as Fig.10 As shown, due to Fig. 9 The form filling node in contains two outflow lines. Therefore, when the form filling node completes the form filling, the third process tracking diagram constructed will activate two process instances at the same time, namely execution 1 and execution 2. Execution 1 can be expressed in words as: start event → line 1 → form filling node → line 2 → approval 1 node. Execution 2 can be expressed in words as: start event → line 1 → form filling node → line 3 → approval 2 node. Different process instances will have different ids, different instance objects, and different storage spaces, which means that they can be executed in parallel without affecting each other. For example, approval 1 and approval 2 can be performed by different users or system components at different time points without waiting for each other to complete. Among them, the numbers in execution 1 and execution 2 represent the ids of the two process instances respectively.
[0078] Fig.11 For the embodiment of the present application provided Fig. 9 The fourth process tracking diagram constructed when the two tasks of approval 1 and approval 2 are executed through the inclusive gateway to the approval 3 node is shown in Fig.11 As shown, Fig.11 The fourth process tracking diagram execution 3 in the text can be expressed as: start event → line 1 → form filling node → diversion node → inclusive gateway → line 6 → approval 3 node. Among them, the diversion node includes two processes, the first process can be expressed as: line 2 → approval 1 node → line 4, and the second process can be expressed as: line 3 → approval 2 node → line 5.
[0079] Specifically, the process in the fourth process tracking diagram starts from the "start event", passes through the "form filling node" and reaches the "divergence node". At the "divergence node", the process is divided into two parallel paths: one path passes through the "approval 1 node" and the other path passes through the "approval 2 node". The inclusive gateway allows the process to execute multiple branches at the same time when it reaches this gateway, instead of selecting only one branch to execute like the exclusive gateway. In this case, the two approvals (approval 1 and approval 2) are executed in parallel. When both approval processes are completed, their respective process instances are merged into one process instance after the inclusive gateway. This is a feature of the Activiti engine for handling the merging of parallel processes. When merging, the id of the process instance will randomly select an inheritance from the previously activated instance, which means that the merged process tracking diagram is visually presented as a single path. This application follows this logic of the Activiti engine and merges the originally parallel process tracking diagrams into one path after the inclusive gateway. This helps to simplify process monitoring and tracking, even though these paths are parallel and independent during physical execution. This application identifies the location of the inclusive gateway in the process definition, and tracks all parallel branches that pass through the inclusive gateway during process execution. When all parallel branches are completed and reach the confluence point of the inclusive gateway, these branches are merged in the process tracking diagram according to Activiti's merge logic (randomly selecting a process instance id). Based on the merged process instance, the process tracking diagram is updated to reflect the current state of the process.
[0080] when Fig. 9 When the flowchart containing the gateway node needs to be rolled back, the process variables are read and the following is constructed: Fig.11The fourth process tracking diagram shown in the figure. Start traversing forward from the tail pointer of the process tracking diagram. This is because we usually focus on the most recently executed parts of the process and want to roll back from these parts. During the traversal process, check whether each node meets the rollback condition (such as whether it is a rollback node type). If this node does not meet the rollback condition, ignore this node and continue to traverse forward. For example, in Fig.11 , line 6 and the inclusive gateway are skipped because they are not fallback nodes. When traversing to the divergence node, since the divergence node is a special node, the sub-process tracking graph of the node will be recursively parsed. This is because the divergence node represents a branch point in the process, and each branch may have a fallback node. In the process of parsing the sub-process tracking graph, check whether each node is a fallback node (such as the approval 1 node and the approval 2 node). If so, add these nodes to the fallback node set. When the traversal is completed and all fallback nodes are collected, select the fallback strategy and select a node from the fallback node set as the target fallback node. Use the planContinueProcessOperation method provided by the Activiti engine to activate the selected target fallback node to perform the fallback operation, update the state of the process instance and the process tracking graph, and thus complete the first fallback step. For example, in Fig.11 In the case of, two tasks, Approval 1 and Approval 2, will be activated for rollback.
[0081] This application can handle complex processes with multiple branches and nested structures by recursively traversing the process tracking graph. Based on node types and business rules, it can accurately identify which nodes can be used as target fallback nodes. By integrating the functions of the Activiti engine, it is easy to activate the fallback task and implement the fallback operation of the process. It provides a flexible fallback mechanism for the process management system, which helps to quickly restore to a previous state when errors occur or changes are required.
[0082] Fig.12 For the application example provided Fig.11 When the approval 1 node and the approval 2 node are activated, the fifth process tracking diagram is constructed, such as Fig.12As shown, the fifth process tracking graph is split into two parts, namely execution 4 and execution 5. Execution 4 can be expressed in words as: start event → line 1 → form filling node → diversion node → inclusive gateway → line 6 → approval 3 node → approval 1 node. Execution 5 can be expressed in words as: start event → line 1 → form filling node → diversion node → inclusive gateway → line 6 → approval 3 node → approval 2 node. If you continue to roll back Approval 1 at this time, the execution process will become: first parse the currently executing process instance (execution 4) and obtain its complete process tracking graph. Starting from the current node (Approval 1), traverse the process tracking graph forward to find possible rollback points. When traversing to the Approval 3 node, the system checks whether the Approval 3 node can be used as the target rollback node. By Fig. 9 It is known that Approval 3 is not the direct predecessor node of Approval 1, so the Approval 3 node does not meet the rollback condition, and the traversal continues forward. When traversing to the diversion node, the diversion logic is parsed and it is found that there are two paths leading to Approval 1 and Approval 2 after the diversion. For the Approval 1 node, since it is the node currently trying to roll back, it is judged that it cannot be used as the target rollback node (that is, it cannot roll back directly to itself). For the Approval 2 node, although it is part of the process, it is not the predecessor node of Approval 1, so it does not meet the rollback condition. At this time, the diversion node, as a key decision point in the process, does not support direct rollback operation itself, and the traversal continues forward. Continue to traverse forward and finally reach the Filling Node. As one of the starting parts of the process, the Filling Node is usually regarded as the farthest target rollback node that can be rolled back to. The system activates the Filling Node and rolls back the state of the process instance (execution 4) to the state after the Filling Node.
[0083] S106: When a common node is encountered during the process of traversing the process tracking graph, a second fallback step is executed.
[0084] Figure 5 A specific flowchart of executing the second fallback step when encountering a common node in the process of traversing the process tracking graph provided by the embodiment of the present application, such as Figure 5 As shown, it includes steps S501 to S505.
[0085] S501: Determine whether the currently traversed common node meets the fallback condition. The fallback condition is: this common node is the predecessor node of the target fallback node, and the node type of this common node is a fallback node type.
[0086] If the common node does not satisfy the fallback condition, that is, the judgment result is no, S502 is executed: the common node is ignored, and the process tracking graph is continued to be traversed forward.
[0087] If the common node meets the rollback condition, that is, the judgment result is yes, execute S503: start the rollback operation from the common node, and after the execution is completed, update the process tracking diagram and the status of the process instance to determine whether the common node is the target rollback node.
[0088] If the common node is the target fallback node, that is, the judgment result is yes, S504 is executed: the fallback operation is completed, and the traversal process tracking graph is ended.
[0089] If the common node is not the target fallback node, the judgment result is no, and S505 is executed: continue to traverse the process tracking graph forward until the target fallback node is found.
[0090] Specifically, the above steps determine whether to perform the rollback operation by traversing the process tracking graph and checking whether each common node meets the rollback condition. If the target rollback node is found, the rollback operation is performed on this node and the traversal ends. If the current node does not meet the condition or is not the target node, the traversal continues until the target rollback node is found or the traversal is completed. This process ensures that the process can accurately roll back to the target rollback node.
[0091] The embodiment of the present application also provides a device 1300 for implementing a node fallback function, such as Fig.13 As shown, the device includes: a receiving module 1301, a reading module 1302, a traversal module 1303, a conditional fallback module 1304, a first fallback step execution module 1305 and a second fallback step execution module 1306.
[0092] The receiving module 1301 is used to receive a rollback request initiated by a user or a system.
[0093] The reading module 1302 is used to read the current process tracking diagram from the variables of the process instance.
[0094] The traversal module 1303 is used to traverse the process tracking graph forward starting from the current node.
[0095] The conditional rollback module 1304 is used to execute corresponding rollback steps according to the node categories encountered in the process of traversing the process tracking graph.
[0096] The module 1305 for executing the first fallback step is used to execute the first fallback step when a special node is encountered during the process of traversing the process tracking graph. Special nodes include inclusive gateway nodes, branch nodes, and merge nodes. When a special node is encountered during the process of traversing the process tracking graph, the first fallback step is executed, including: recursively traversing all sub-process tracking graphs under the special node. All nodes whose node types are fallback node types are aggregated to form a fallback node set. A fallback strategy is selected, and a node is selected from the fallback node set as the target fallback node. Among them, the fallback strategy includes: fallback to the predecessor node, fallback to the source node, and fallback to the start node. Use the interface provided by the process engine to activate the selected target fallback node. Update the status of the process instance and the process tracking graph to complete the first fallback step.
[0097] The module 1306 for executing the second fallback step is used to execute the second fallback step when a common node is encountered during the process of traversing the process tracking graph.
[0098] Some modules in the apparatus described in the present application can be described in the general context of computer executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, classes, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0099] The devices or modules described in the above application embodiments can be implemented by computer chips or entities, or by products with certain functions. For the convenience of description, the above devices are described in various modules according to their functions. When implementing the embodiments of the present application, the functions of each module can be implemented in the same or multiple software and / or hardware. Of course, the module that implements a certain function can also be implemented by combining multiple sub-modules or sub-units.
[0100] The methods, devices or modules described in this application can be implemented in the form of computer-readable program codes. The controller can be implemented in any appropriate manner. For example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program codes (such as software or firmware) that can be executed by the (micro)processor, logic gates, switches, application-specific integrated circuits (English: Application Specific Integrated Circuit, referred to as: ASIC), programmable logic controllers and embedded microcontrollers. Examples of controllers include but are not limited to the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20 and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that in addition to implementing the controller in the form of pure computer-readable program codes, the controller can be implemented in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers and embedded microcontrollers by logically programming the method steps. Therefore, this controller can be considered as a hardware component, and the devices included in it for implementing various functions can also be regarded as structures within the hardware component. Or even, the means for realizing various functions may be regarded as both a software module for realizing the method and a structure within a hardware component.
[0101] like Fig.14 As shown, an embodiment of the present application also provides a server for implementing a node fallback function, including a memory 1401 and a processor 1402; the memory 1401 is used to store computer executable instructions; the processor 1402 is used to execute computer executable instructions to implement a method for implementing a node fallback function described above in an embodiment of the present application.
[0102] An embodiment of the present application also provides a computer-readable storage medium, which stores executable instructions. When a computer executes the executable instructions, it can implement a method for implementing a node fallback function described above in the embodiment of the present application.
[0103] It can be seen from the description of the above implementation methods that those skilled in the art can clearly understand that the present application can be implemented by means of software plus necessary hardware. Based on this understanding, the technical solution of the present application can be essentially or partly contributed to the prior art in the form of a software product, or it can be reflected in the implementation process of data migration. The computer software product can be stored in a storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a mobile terminal, a server, or a network device, etc.) to execute the method described in the embodiment of the present application.
[0104] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. All or part of this application can be used in many general or special computer system environments or configurations.
[0105] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit the present application. Although the present application has been described in detail with reference to the aforementioned embodiments, a person of ordinary skill in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some or all of the technical features thereof may be replaced by equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the present application.
Claims
1. A method for implementing a node fallback function, characterized in that: include: Receive rollback requests initiated by users or systems; Before receiving the rollback request initiated by the user or the system, the process includes: creating a process instance according to the preset process definition and initializing its state; executing each node in the process one by one according to the sequence or conditional logic in the process definition; updating the state of the process instance and the process tracking diagram during the execution of each node; wherein the process tracking diagram records all execution paths and state changes of the process instance from the beginning to the present; Read the current process tracking diagram from the variables of the process instance; Starting from the current node, traverse the process tracking graph forward; Execute corresponding fallback steps according to the node categories encountered in the process of traversing the process tracking graph; When encountering a special node during traversal of the process tracking graph, executing a first fallback step; the special node includes an inclusive gateway node, a branch node, and a merge node; When a normal node is encountered during the traversal of the process tracking graph, the second fallback step is executed; When a common node is encountered during the traversal of the process tracking graph, a second fallback step is executed, including: determining whether the common node currently traversed meets the fallback condition; if the common node does not meet the fallback condition, ignoring the common node and continuing to traverse the process tracking graph forward; if the common node meets the fallback condition, performing the fallback operation from this common node, and after the execution is completed, updating the state of the process tracking graph and the process instance, and determining whether the common node is the target fallback node; if the common node is the target fallback node, the fallback operation is completed, and the traversal of the process tracking graph ends; if the common node is not the target fallback node, continuing to traverse the process tracking graph forward until the target fallback node is found; The fallback condition is: the common node is a predecessor node of the target fallback node, and the node type of the common node is a fallback node type; When encountering a special node in the process of traversing the process tracking graph, executing a first fallback step includes: Recursively traverse all sub-process tracking graphs under a special node; Aggregate all nodes whose node types are fallback node types to form a fallback node set; Select a fallback strategy, and select a node from the fallback node set as a target fallback node; wherein the fallback strategy includes: fallback to a previous node, fallback to a source node, and fallback to a start node; Use the interface provided by the process engine to activate the selected target fallback node; Update the state of the process instance and the process tracking diagram to complete the first fallback step.
2. The method according to claim 1, characterized in that In the process of executing each node, the state of the process instance and the process tracking diagram are updated, including: When the node is a special node, the corresponding operation is performed according to the type and execution logic of the special node. After the execution is completed, the process tracking diagram and the status of the process instance are updated according to the execution result; When the node is a normal node, the defined operation is directly executed. After the execution is completed, the process tracking diagram and the status of the process instance are updated.
3. The method according to claim 2, characterized in that In the process of executing each node, updating the state of the process instance and the process tracking diagram also includes: During the execution of a node, if the process needs to wait for an external event, the execution of the current node is paused, and a monitoring mechanism is set up to wait for and respond to the corresponding event.
4. A device for implementing a node fallback function, characterized in that: include: A receiving module, used for receiving a rollback request initiated by a user or a system; Before receiving the rollback request initiated by the user or the system, the process includes: creating a process instance according to the preset process definition and initializing its state; executing each node in the process one by one according to the sequence or conditional logic in the process definition; updating the state of the process instance and the process tracking diagram during the execution of each node; wherein the process tracking diagram records all execution paths and state changes of the process instance from the beginning to the present; The reading module is used to read the current process tracking diagram from the variables of the process instance; The traversal module is used to traverse the process tracking graph forward starting from the current node; A conditional fallback module, used to execute corresponding fallback steps according to the node categories encountered in the process of traversing the process tracking graph; A module for executing a first fallback step is used to execute a first fallback step when encountering a special node in the process of traversing a process tracking graph; the special node includes an inclusive gateway node, a branch node, and a merge node; the module for executing a first fallback step when encountering a special node in the process of traversing a process tracking graph includes: recursively traversing all sub-process tracking graphs under the special node; aggregating all nodes whose node types are fallback node types to form a fallback node set; selecting a fallback strategy, and selecting a node from the fallback node set as a target fallback node; wherein the fallback strategy includes: fallback to a predecessor node, fallback to a source node, and fallback to a start node; using an interface provided by a process engine to activate the selected target fallback node; updating the state of the process instance and the process tracking graph to complete the first fallback step; A module for executing a second back-off step is used to execute a second back-off step when encountering an ordinary node during traversal of a process tracking graph; the module for executing a second back-off step when encountering an ordinary node during traversal of a process tracking graph includes: determining whether the ordinary node currently traversed satisfies the back-off condition; if the ordinary node does not satisfy the back-off condition, ignoring the ordinary node and continuing to traverse the process tracking graph forward; if the ordinary node satisfies the back-off condition, executing a back-off operation starting from the ordinary node, and after the execution is completed, updating the process tracking graph and the status of the process instance to determine whether the ordinary node is a target back-off node; if the ordinary node is a target back-off node, the back-off operation is completed and traversal of the process tracking graph ends; if the ordinary node is not a target back-off node, continuing to traverse the process tracking graph forward until the target back-off node is found; the back-off condition is: the ordinary node is a predecessor node of the target back-off node, and the node type of the ordinary node is a back-off node type.
5. A server for implementing a node fallback function, characterized in that: including memory and processor; The memory is used to store computer executable instructions; The processor is used to execute the computer executable instructions to implement the method according to any one of claims 1 to 3.
6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores executable instructions, and when a computer executes the executable instructions, the method according to any one of claims 1 to 3 can be implemented.
Citation Information
Patent Citations
Retroversion method and device in workflow management system
CN101615269A
Method for realizing reverse circulation based on Activiti workflow
CN110619473A
Activiti-based process rollback method and device and storage medium
CN113687882A
Workflow rollback method, device, equipment and medium
CN115562764A
Method and device for backspacing between workflow nodes and medium
CN116775377A
