Business status transfer and orchestration processing method, device and equipment

By combining stateful and stateless state machines, the problem of large memory usage and unintuitive state display in the logistics and transportation process management system is solved, and efficient business state flow is achieved.

CN119228105BActive Publication Date: 2025-07-18BEIJING ZHIJIAN ENERGY CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411419010.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-11
Publication Date
2025-07-18
Estimated Expiration
2044-10-11

AI Technical Summary

Technical Problem

When traditional logistics and transportation process management systems handle business state flow, there is a problem that the memory occupies a large amount of memory and cannot intuitively display the current state.

Method used

A state machine combining state and stateless state is adopted, and a state process template is used to realize business state state flow by creating a state process instance as a stateful state machine and a state process template as a stateless state machine.

Benefits of technology

It reduces the system memory usage, improves the performance of the state flow system, and can intuitively display the current status of the business.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119228105B_ABST
    Figure CN119228105B_ABST
Patent Text Reader

Abstract

The present disclosure provides a method for orchestrating and processing business status transitions, specifically including: when a trigger event is received, querying a state machine process instance corresponding to the waybill event request according to the trigger event, wherein the state machine process instance is created based on an initial business waybill, and the business status information of the business waybill is included in the process instance; obtaining the current status of the waybill according to the state machine process instance, and querying a process template corresponding to the trigger event; wherein, the process template includes state machine rule configuration information; obtaining an operation list corresponding to the trigger event according to the process template, and traversing and executing each operation according to the operation list, thereby completing the status transition of the trigger event. The above processing method combines the use of a stateful state machine and a stateless state machine to process business status transitions, solves the problems existing in the use of a stateful state machine alone and a stateless state machine alone, and effectively improves the performance of the status transition system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of data processing, and particularly to a method, apparatus, and device for choreographing and processing business state transitions. Background Art

[0002] The status transition of waybills is the most core link in the field of bulk transportation. The waybill link is long, and the waybill status is changeable, which needs to meet the adaptation of multiple tenants, multiple scenarios, and multiple dimensions. Traditional logistics transportation process management systems usually use separate stateful state machines or stateless state machines to process business state transitions. When a stateful state machine processes business state transitions, the memory occupancy is relatively large; while a stateless state machine has the problem that it cannot intuitively display the current state of the business. Therefore, how to design a system that can both intuitively display the current state of the business and does not occupy too much system memory to process business state transitions has become an urgent problem for researchers in this field. Summary of the Invention

[0003] In view of this, the present disclosure proposes a method, apparatus, and device for choreographing and processing business state transitions, which can both intuitively display the current state of the business and does not occupy too much system memory to process business state transitions. The present disclosure uses the created state process instance as a stateful state machine, and the state process template as a stateless state machine, so that during the business state transition process, the state process instance only needs to call the corresponding state process template and complete the business state transition according to the state process template. This reduces the complexity of business system access and improves the performance of the state transition system at the same time.

[0004] According to a first aspect of the present disclosure, there is provided a method for choreographing and processing business state transitions, including:

[0005] When a trigger event is received, query a corresponding state machine process instance according to the trigger event, where the state machine process instance is created and generated according to an initial business waybill, and the process instance contains business state information of the business waybill;

[0006] Obtain the current state of the waybill according to the state machine process instance, and query a process template corresponding to the trigger event; where the process template contains state machine rule configuration information;

[0007] Obtain an operation list corresponding to the trigger event according to the process template, and traverse and execute each operation according to the operation list, thereby completing the state transition of the trigger event.

[0008] In a possible implementation manner, when querying a corresponding state machine process instance according to the trigger event, it includes:

[0009] Extract waybill information from the trigger event;

[0010] Query the state machine process instance based on the waybill information.

[0011] In a possible implementation, after obtaining the current state of the waybill according to the state machine process instance and querying the process template corresponding to the trigger event, it further includes:

[0012] Determine whether the trigger event matches the current state of the waybill;

[0013] When it is determined that the trigger event matches the current state of the waybill, perform the step of obtaining the operation list corresponding to the trigger event according to the process template.

[0014] In a possible implementation, after obtaining the operation list corresponding to the trigger event according to the process template and traversing and executing each operation according to the operation list, it further includes:

[0015] Determine whether the state transition condition is satisfied;

[0016] When it is determined that the state transition condition is satisfied, trigger the next trigger event.

[0017] In a possible implementation, when determining whether the state transition condition is satisfied, it includes:

[0018] Record the successful execution of the current event in redis and mysql, then obtain the execution status of other events of the current state from redis, and mark the execution status of other events;

[0019] Then perform a logical operation according to the configured transition expression to obtain a boolean value;

[0020] When the boolean value is true, it indicates that the state transition condition is satisfied.

[0021] In a possible implementation, when determining whether the trigger event matches the current state of the waybill, it further includes:

[0022] When it is determined that the trigger event does not match the current state of the waybill, determine the trigger event;

[0023] When it is determined that the trigger event is an out-of-order event, start the operation of the out-of-order event handling process;

[0024] Wherein, the out-of-order event is an event in which the current trigger node is inconsistent with the configured trigger node among the events configured for the business waybill.

[0025] In a possible implementation, the out-of-order event handling process includes:

[0026] Persist the out-of-order event into a dedicated out-of-order event table;

[0027] Then mark the out-of-order event in the out-of-order event table as the "skipped" state, and maintain an ordered queue of skipped events in memory;

[0028] Capture the context of the current state machine of the out-of-order event according to the out-of-order event;

[0029] Perform a priority assessment on the out-of-order event according to the assessment factors; wherein, the assessment factors include at least one of the importance of the event type, the chronological order of event occurrence, and the degree of business impact.

[0030] In a possible implementation manner, when it is determined that the trigger event is an abnormal event, an abnormal prompt is issued;

[0031] Wherein, the abnormal event is an event triggered by a user's misoperation.

[0032] According to a second aspect of the present disclosure, there is provided an apparatus for business state transition orchestration processing, including:

[0033] A process instance query module, configured to query a corresponding state machine process instance according to the trigger event when receiving the trigger event, wherein the state machine process instance is created based on an initial business waybill, and the process instance contains business state information of the business waybill;

[0034] A process template query module, configured to obtain the current state of the waybill according to the state machine process instance, and query a process template corresponding to the trigger event; wherein, the process template contains state machine rule configuration information;

[0035] A business state transition module, configured to obtain an operation list corresponding to the trigger event according to the process template, and traverse and execute each operation according to the operation list, thereby completing the state transition of the trigger event.

[0036] According to a third aspect of the present disclosure, there is provided a business state transition orchestration processing device, including: a processor; a memory for storing processor-executable instructions; wherein, the processor is configured to execute the method described in the first aspect of the present disclosure.

[0037] The present disclosure provides a method for choreographing and processing business state transitions, which specifically includes: when a trigger event is received, querying a state machine process instance corresponding to the waybill event request according to the trigger event, where the state machine process instance is created based on an initial business waybill, and the business state information of the business waybill is included in the process instance; obtaining the current state of the waybill according to the state machine process instance, and querying a process template corresponding to the trigger event; where the process template includes state machine rule configuration information; obtaining an operation list corresponding to the trigger event according to the process template, and traversing and executing each operation according to the operation list, thereby completing the state transition of the trigger event. The above processing method completes the business state transition by using a stateful state machine and a stateless state machine in combination, achieving both an intuitive display of the current business state and not occupying too much system memory to process the business state transition. The present disclosure uses the created state process instance as the stateful state machine and the state process template as the stateless state machine, so that during the business state transition process, the state process instance only needs to call the corresponding state process template and complete the business state transition according to the state process template. It reduces the complexity of accessing the business system and improves the performance of the state transition system at the same time.

[0038] Other features and aspects of the present disclosure will become apparent from the following detailed description of exemplary embodiments with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] The accompanying drawings, which are included in and constitute a part of this specification, illustrate exemplary embodiments, features, and aspects of the present disclosure together with the specification and are used to explain the principles of the present disclosure.

[0040] Figure 1 A flowchart showing a method for choreographing and processing business state transitions according to an embodiment of the present disclosure;

[0041] Figure 2 A schematic flowchart showing a method for choreographing and processing business state transitions according to another embodiment of the present disclosure;

[0042] Figure 3 A schematic block diagram showing a device for choreographing and processing business state transitions according to an embodiment of the present disclosure;

[0043] Figure 4 A schematic block diagram showing a device for choreographing and processing business state transitions according to an embodiment of the present disclosure. DETAILED DESCRIPTION

[0044] Various exemplary embodiments, features, and aspects of the present disclosure will be described in detail below with reference to the accompanying drawings. Like reference numerals in the drawings denote elements having the same or similar functions. Although various aspects of the embodiments are shown in the drawings, the drawings are not necessarily drawn to scale unless otherwise specified.

[0045] As used herein, the term "exemplary" means "serving as an example, embodiment, or illustration". Any embodiment described as "exemplary" herein need not be construed as superior or better than other embodiments.

[0046] In addition, for a better illustration of the present disclosure, numerous specific details are given in the following detailed description. Those skilled in the art should understand that the present disclosure can also be implemented without some of these specific details. In some instances, methods, means, elements, and circuits well known to those skilled in the art are not described in detail so as to highlight the gist of the present disclosure.

[0047] <Method Embodiment>

[0048] Figure 1 A flowchart showing a method for choreographing the flow of business states according to an embodiment of the present disclosure is presented. Specifically, it includes: Step S1100, when a trigger event is received, query the corresponding state machine process instance according to the trigger event, where the state machine process instance is created based on an initial business waybill, and the process instance contains the business state information of the business waybill; Step S1200, obtain the current state of the waybill according to the state machine process instance, and query the process template corresponding to the trigger event; where the process template contains state machine rule configuration information; Step S1300, obtain the operation list corresponding to the trigger event according to the state machine rule configuration information recorded in the process template, and traverse and execute each operation according to the operation list, thereby completing the state transition of the trigger event.

[0049] Thus, a method for choreographing the flow of business states provided by the present disclosure, after receiving a trigger event, queries the corresponding state machine process instance according to the trigger event, and then further obtains the current state of the waybill according to the state machine process example, and determines the corresponding process template, and then performs the state transition according to the process template. Among them, since the state machine process instance is created based on the initial business waybill and contains the business state information of the business waybill, the state machine process instance can be used as a stateful state machine, and the process template contains state machine rule configuration information and can thus be used as a stateless state machine. This enables the business state flow choreography method of the present disclosure to effectively combine a stateful state machine and a stateless state machine, and achieve business state flow through this combination. Compared with the conventional method of only performing business state flow through a stateful state machine or a stateless state machine alone, it simultaneously solves the technical problems of the large memory occupation and overly complex state transition caused by the stateful state machine, and also effectively solves the problem that the stateless state machine method cannot intuitively display the current state of the business.

[0050] Among them, it should be noted that when creating a state machine process instance according to the initial business waybill, it can be implemented in the following way. That is, initialize the operation by calling the initialization interface of the state machine engine. After receiving a new waybill request, directly create the corresponding process instance according to the waybill request. Among them, the created process instance contains the business status information of the business waybill, and can also contain information such as the waybill number, the initial state of the waybill, and the current process instance node of the business waybill. Here, it should be noted that the created state machine process instance is directly saved to the database, so that for this business waybill, every time a new event is triggered, the state machine process instance can be directly called from the database, and there is no need to reconstruct the process instance again.

[0051] At the same time, after receiving a new waybill request, it also includes the operation of obtaining the corresponding business type of the waybill through the waybill request, and then determining the corresponding state process template according to the business type.

[0052] Here, it should be noted that in the technical solution of the present disclosure, the state process template is pre-constructed. The state process template contains state machine rule configuration information. Here, it should be noted that the state machine rule configuration information refers to the association relationship among the business status, the event, and the operations associated with each event. That is to say, the business status information and the trigger events configured under each business status, and the operations associated with each trigger event are recorded in the state process template. Among them, there can be multiple trigger events configured under the business status, and similarly, there can be multiple operations associated with each trigger event. The multiple operations are represented by an operation list.

[0053] That is, when performing business status transition orchestration through the business status transition orchestration method of the present disclosure, it is necessary to pre-construct the state process template, store the pre-created state process template in the database, and at the same time persistently store the created process instance in the database. This realizes the uniqueness of the state process template and the persistent storage of the process instance when combining the stateful state machine and the stateless state machine for business status transition orchestration, which can not only enable the business system to not need to pay attention to the state transition, but be fully processed by the framework layer, but also solve the problem of the stateful state machine occupying memory.

[0054] Among them, in a possible implementation manner, when constructing the state process template, it can be implemented in the following way.

[0055] As described above, the process template records the state machine rule configuration information. Here, it should be noted that the state machine rule configuration information refers to the association relationships among business states, events, and operations. That is, the events associated with each business state, and the operations associated with each event, etc. information. By configuring the associated events for each business state and configuring the associated operations for each event, the corresponding process template is finally generated.

[0056] Specifically, refer to Figure 2 As shown, when creating a process template, first, the business system defines the state pool, event pool, operation pool, and the binding relationship between events and operations for the business. Among them, the state pool contains multiple business state information, the event pool contains multiple trigger events, and the operation pool contains multiple operations. Here, it should be noted that the data in the state pool, event pool, and operation pool can be directly implemented through manual definition.

[0057] After the above data definitions are made through the business system, the defined state pool, event pool, operation pool, the binding relationship between events and operations, and the rule information of business state transitions can also be stored in the data for direct invocation when constructing the process template.

[0058] Specifically, refer to Figure 2 As shown, when constructing a process template, according to the business type, the corresponding flowchart of business state transitions will be established first. Here, it should be noted that this flowchart contains all the business states required by the business type and the transition order between each business state. Then, according to the business type, all the business states included in the business type are extracted from the state pool. Furthermore, for each business state included in the business type, the corresponding events are configured for each business state respectively. Among them, when configuring events for a given business state, the corresponding events are directly obtained from the event pool predefined above. At the same time, when configuring events for each business state, the corresponding events can be flexibly selected according to the actual situation, and no specific limitation is made here.

[0059] Next, according to the events configured for each business state, combined with the binding relationship between events and operations defined above, the operations corresponding to each event are retrieved from the operation pool, and the operations bound under each event are represented in the form of a list. Thus, the construction of the process template can be completed.

[0060] Among them, those skilled in the art can understand that in the solution of the present disclosure, multiple pre-constructed state process templates can be provided, and each process template corresponds to a different business type. That is to say, when constructing the process template, it can be constructed based on the business type, and different business types correspond to different process templates. Thus, when generating a business waybill of the same business type, directly call the process template corresponding to the business type to achieve the business state transfer orchestration, without the need to construct a new process template.

[0061] After constructing the process template in the above manner, the process template can be stored in the database to facilitate the system to search and use it during business state transfer. In a possible implementation manner, when saving the constructed process template, the system can directly call the backend save interface to convert each state process template corresponding to the business type into json characters and store them in the database for saving, or first perform a legality check on the rules configured in the constructed process template and then call the backend save interface to convert each state process template corresponding to the business type into json characters and store them in the database for saving. The specific method is not limited.

[0062] Among them, when performing a legality check on the rules configured in the constructed process template, the responsibility chain pattern is used for the check. Specifically, the system will first define multiple validators according to the node types in the flow chart configured in the process template. When performing the check, a validator is defined for each type of node in the process template for the check. The specific definition of the validator is not limited. Usually, it includes at least one of the start node validator, end node validator, status node validator, process structure validator, and process data validator. Then, the defined multiple validators are combined to form a link. Each point in the link corresponds to a validator, and each validator performs a legality check on the node of the corresponding node type in the constructed process template. When the entire link is completely checked, the legality check of the corresponding process template is completed, and then the process template that has passed the check is stored in the database for subsequent state transfer. It should be noted that the order of the various validators that form a link for the check can be flexibly determined and is not specifically limited.

[0063] Among them, when each validator validates the process template, it includes: The start node validator will validate the start node of the process template, checking whether the own attributes of the start node are empty and whether the start condition and end condition are correct. The end node validator will validate the end node in the process template, checking whether the own attributes of the end node are empty and whether the start condition and end condition are correct. The status node validator will validate the status nodes in the process template, checking whether the own attributes are correct, whether the start condition and end condition are correct, and whether the transfer rules are configured. The process structure validator will validate the connection of each node in the process template, the specified nodes of the connection lines, and the matching of each node and the connection lines. When the process data validator validates the process template, it includes whether the configured events exist in the database, whether the configured rule expressions and the logical operators and events in the expressions are correct, whether the configured events are repeated, and whether the events with some special configurations meet the requirements when bound to the outgoing lines of the specified status nodes. It should be noted that the above validations of the process template are all based on the business transfer rules pre-configured in the business system. When there is an inconsistency between the rules configured in the process template and the configuration rules defined in the business system during the validation, the corresponding process template will be rebuilt to ensure that the system can accurately perform status conversion according to the built process template during the business status transfer, and there will be no situation where the business status conversion goes wrong due to problems in building the process template. The legal validation of the process template improves the correctness of building the process template.

[0064] Furthermore, based on the built process template, when creating a process instance, the process instance can be directly created according to the flow chart corresponding to the process template found according to the business type. Specifically, when the system receives a new waybill request, it will search for the corresponding process template according to the business type carried in the waybill request. After finding the corresponding process template, it will obtain the corresponding flow chart configured in the front end according to the process template, and directly create a process instance based on the obtained flow chart and the waybill request, making the creation of the process instance more rapid and convenient, and improving the performance of the system.

[0065] Even further, as shown in Figure 2 the business system also defines the front-end page components corresponding to each business status included in each business type and the binding relationship between the front-end page components and the events. Among them, the front-end page components include at least one configuration item of button, style, icon, and display text.

[0066] By defining front-end page components corresponding to each business state included in each business type, the dynamic styling of the front-end page of the system in different scenarios and different states is achieved. The defined binding relationship between components and events enables the triggering of business state transitions by directly clicking on button components in the front-end page when the business state transitions. The bound event is the trigger event, realizing the dynamicization of business logic. At the same time, by separately configuring the event bindings for the defined front-end page components, when a user triggers an event, they can directly trigger the front-end page component, which further simplifies the event triggering operation method and makes event triggering more intuitive and convenient.

[0067] Meanwhile, in the method of the present disclosure, operation interfaces can also be defined through the business system, and the binding relationship between the operation interfaces and the post-operation logic, the mapping relationship between the trigger event and the operation interface, and the mapping relationship between the state name and the operation interface can be configured. Among them, the post-operation logic refers to what post-operation needs to be performed after the business state transitions to a certain state node. For example, what post-logic operation needs to be performed after the waybill transitions to waiting for loading, such as sending a notification or modifying the business database. The operation interface is a type of atomic action component used to define the operations performed after the trigger event and the state transition. The same operation interface can be reused for different states. For example, after triggering the inbound event, a message needs to be sent.

[0068] During subsequent business state transitions, after the trigger event is triggered, subsequent business state transitions can be directly performed, or it can be determined whether to perform the corresponding post-operation logic after the trigger event is triggered according to the defined mapping relationship between the trigger event and the operation interface, and then subsequent business state transitions are performed. When determining whether to perform the corresponding post-operation after the trigger event is triggered, if it is determined to perform the corresponding post-operation, the business system will call the defined operation inlet to perform the post-operation bound to the operation interface, and after completing the corresponding post-operation, the business state is converted; if no post-operation is performed, the subsequent business state transitions are directly entered.

[0069] In a possible implementation manner, after the business state transition is completed, the current business state can be directly returned, or it can be determined whether to perform the corresponding post-operation according to the defined mapping relationship between the state name and the operation interface, and then the current business state is returned. When determining whether to perform the corresponding post-operation after the business state conversion, if it is determined not to perform the corresponding post-operation, the current business state is directly returned; if it is determined to perform the corresponding post-operation, the corresponding operation interface is called, and after completing the bound post-operation, the current business state is returned.

[0070] After completing the front - end flowchart configuration (i.e., the definition of front - end components and the binding of components to events) and the configuration of back - end business states and operation logics (i.e., the construction of process templates) in the above - mentioned manner, the state transition orchestration method of the present disclosure can be executed. Among them, when performing business state transitions, refer to Figure 2 the state transition process shown for business state transitions.

[0071] Here, it should be noted that when executing the state process orchestration method of the present disclosure, the state process orchestration is performed for each waybill. Therefore, a new waybill needs to be generated first. After generating the new waybill, call the initialization interface of the framework state machine engine for initialization operations. At the same time, the state machine framework layer waits to receive waybill requests. After receiving a waybill request, directly search for the process template according to the business type in the waybill request.

[0072] In a possible implementation, the corresponding process template can be searched for in memory first. If the corresponding process template is found in memory, directly use this process template for business state transitions. If the process template is not found in memory, search in the database and then cache the found process template in memory. Through this operation, when a waybill request of the same type as this business waybill occurs next time, the process template can be directly called from memory without having to repeat the search for the process template in the database, which effectively reduces the number of interactions with the database and further improves the efficiency of business state transition orchestration.

[0073] After obtaining the state machine process instance and process template corresponding to the current business waybill through the above steps, the business state transition orchestration can be performed according to the triggered event. Among them, the triggered event is triggered only after receiving the waybill request. In a possible implementation, the triggering of events is divided into two types, one is user - triggered and the other is system - internally triggered. For user - triggered events, through the pre - defined front - end components mentioned above, the user can trigger by triggering the components. Internal triggering refers to some events that are custom - defined and triggered regularly within the system.

[0074] Furthermore, when performing business state transitions, the business state can be directly transitioned according to the triggered event, or it can be determined whether the triggered event has post - operation logics first and then the business state is transitioned. Among them, when it is determined according to the mapping relationship between the triggered event and the operation interface defined by the business system that the triggered event does not have post - operation logics, the subsequent business state is directly transitioned. When it is determined that the triggered event has post - operation logics, the system will call the corresponding operation interface, and after completing the post - operation, the business state is transitioned.

[0075] Meanwhile, before the business status is transferred, the business system will query the corresponding waybill data based on the waybill information carried in the received waybill request, and encapsulate the waybill data into the context of the state machine. After obtaining the trigger event and the state machine context, the system will call the fireEvent interface of the state machine engine, and hand over the trigger event, waybill information, the unique identifier of the event, and the state machine context to the control of the state machine engine for business status transfer. Among them, the fireEvent interface is customized by the state machine engine and is common knowledge in this field, so no more details will be provided here.

[0076] Among them, the waybill information includes the waybill number. When the state machine engine controls the business status transfer, it first judges whether the trigger event matches the current state of the waybill according to the association relationship between various business statuses and events recorded in the state machine rule configuration information in the obtained process template. If they match, the normal business status transfer will be carried out; if they do not match, an exception prompt will be directly thrown.

[0077] Specifically, when the business status transfer is carried out after judging that the trigger event matches the current state of the waybill, first, according to the association relationship between various events and operations recorded in the state machine rule configuration information in the process template, the operation list corresponding to the trigger event is found from the binding relationship between the events and operations recorded in the configuration information. Then, according to the found operation list, each operation in the operation list is traversed and executed. Among them, if an exception occurs during the execution of each operation in the operation list, the current trigger event will be marked as failed and stored in the database. At this time, the state machine engine will inform the business system that the trigger fails, and the business system will search for the same trigger event and hand over the found trigger event to the state machine engine to re - perform the business status transfer. If the execution is completed normally during the execution process, the next status transfer will be carried out at this time.

[0078] It should be noted that it is necessary to judge whether the conditions for status transfer are met before the next status transfer. Specifically, record the successful execution of the current event in redis and mysql, then obtain the execution status of other events in the current state from redis and mark them as executed or not executed. Then, logical operations are performed according to the transfer expression configured in the configuration, and finally a boolean value true or false is obtained. The transfer expression can be expressed by the formula:

[0079] (A1∧A2∧...∧A n )∨(B1∨B2∨...∨B m )∨(C1∧(C2∨C3)∧C4)∨...

[0080] In the formula, ∧ represents the and operator, and ∨ represents the or operator. A, B, and C represent different types of events, n represents there are n events of type A, A n represents the nth event of type A, m represents there are m events of type B, B m represents the mth event of type B, the parentheses represent different combinations, and the expression represents performing a logical operation on the combinations of different types of events to calculate the Boolean value.

[0081] After calculating the Boolean value, if the Boolean value is false, it means that the events matching the current state have not been executed completely, and the business state transition is not performed; if it is true, it means that all the events matching the current state have been executed, and the subsequent state transition link is entered.

[0082] After the business state transition is completed, the system will record the state transition log and return the current business state and the configuration information of the current state node. Further, after the business state transition is completed, according to the configuration information, it is determined whether to perform the corresponding post-operation logic. When it is determined not to perform the post-operation logic, the system will record the state transition log and return the current business state and the configuration information of the current state node. When performing the post-operation logic, the system will call the configured operation interface to perform the corresponding subsequent operations, then record the state transition log, and return the current business state and the configuration information of the current state node.

[0083] Further, when it is determined that the trigger event does not match the current state of the waybill, the system will throw an exception prompt. At the same time, the system will judge the trigger subject of the event according to the event attributes carried by the event. When it is judged that the trigger subject of the event is an event triggered by the user (i.e., a user event), it is determined as an abnormal event, and the system will start the abnormal event handling process; when it is judged that the trigger subject of the event is an event custom-triggered inside the system (i.e., an internal event), the trigger event is determined as an out-of-order event, and the system will start the out-of-order event handling process.

[0084] It should be noted that internal events are pushed by external servers or generated by scheduled tasks and message queues. Out-of-order events are events that occur when internal events are out of order, that is, when an internal event is triggered, the currently triggered node is inconsistent with the configured node that should be triggered. Abnormal events are events caused by user misoperations that result in the trigger event being inconsistent with the current business state node.

[0085] More specifically, when determining that the trigger event is an out-of-order event and starting the out-of-order event handling process, the following method can be used:

[0086] First, to ensure that the event information of out-of-order events is not lost in the event of a system failure, the system will first create a dedicated out-of-order event table and persist the complete event information of out-of-order events into the dedicated out-of-order event table for storage. Among them, when storing out-of-order events, the stored information includes at least one of the event ID, event type, trigger time, associated service ID, request parameters (in JSON format), processing status, and priority of the out-of-order event.

[0087] Then, mark each out-of-order event in the out-of-order event table as the "skipped" state. At the same time, to facilitate subsequent processing of out-of-order events, the system will maintain an ordered queue of skipped events (out-of-order events) in memory. Among them, to facilitate the search and update of the ordered queue, the ordered queue can be stored using a balanced tree data structure, and the tree nodes of the balanced tree contain at least one of the event ID, priority, and timestamp. When sorting, it is preferred that the priority is the main sorting key and the timestamp is the secondary sorting key. It should be noted that through the above sorting method, the time complexity of insertion, deletion, and search operations in the balanced tree can all be O(log n). It should be noted that the skipped event is the event after the out-of-order event is marked.

[0088] Furthermore, when storing out-of-order events, in addition to storing the information of the out-of-order events themselves, it is also necessary to capture the context of the current state machine of the out-of-order events, including at least one of the current business state, system timestamp, and key business metrics.

[0089] Finally, perform a priority evaluation on the out-of-order events. The higher the priority, the earlier it will be processed in subsequent processing. Among them, the priority of the out-of-order events can be defined by the business system, including directly configuring when configuring events in the business system. For example, it is configured that event A must be executed prior to event B. And it is evaluated according to evaluation factors. When evaluating, the business system is allowed to customize the weights of the evaluation factors and calculate the priority of the event using a weighted scoring model. Among them, the evaluation factors include at least one of the importance of the event type, the time sequence of the event occurrence, and the degree of business impact. It should be noted that calculating the priority of time using a weighted scoring model is common knowledge in the art and will not be elaborated here. If the business system does not define it, a default priority policy can also be adopted, and the event priority is recorded according to the event acceptance time. The specific details are not limited.

[0090] After the above processing of the out-of-order events, the processed out-of-order events will be stored in the database. At the same time, after the above processing of the out-of-order events, the state machine remains in the current state, does not trigger events, and does not perform state transitions, waiting for subsequent event triggers.

[0091] When the next trigger event is triggered, the normal business state transition can be directly performed according to the trigger event. It is also possible to first determine whether the current trigger event exists in the ordered queue maintained in memory. If it does not exist, the normal business state transition process is carried out. If it exists, the out-of-order event found at this time and the trigger event are the same event, indicating that the stored out-of-order event is the correct trigger event for the current state node. The out-of-order event became an out-of-order event because the trigger event was inconsistent with the event that should have been triggered by the current state node and was stored in the database. At this time, the out-of-order event found in the ordered queue will be retrieved from the database as the trigger event for subsequent state transitions.

[0092] Specifically, when using the retrieved out-of-order event as the trigger event for state transition, the state machine engine will reconstruct the state machine environment when the out-of-order event occurred based on the context information of the state machine stored in the database, including at least one of the request parameters, trigger nodes, and business custom passed parameters.

[0093] Immediately afterwards, the system will start the intelligent decision-making engine for each out-of-order event to determine the target state of the business state transition. Specifically, because in the process of business state transition, the same event may be combined in different transition rules as a factor for logical operations, and in the transition rules, this event may flow to state A or state B. At this time, for this situation, the intelligent decision-making engine will make an intelligent decision in combination with the decision factors to determine the target state of the event transition and perform the state transition. For example, in the list review link, according to at least one of the list approval results, approval times, and approval content associated with the waybill, based on the pre-configured business rules, the intelligent decision-making engine will determine the target state to which this event should transition. For example, if the list review is rejected more than 3 times, the state transitions to rejected; if the approval is performed by a certain role, the state transitions to a special state.

[0094] Among them, the intelligent decision factors include at least one of the current actual business state, state machine context information, dependencies between events, and business rules pre-specified by the business system. It should be noted that when the intelligent decision-making engine refers to the decision factors to determine the target state of the event transition according to the rule engine of the intelligent decision-making engine, the rule engine supports dynamic rule loading, allowing the business system to update the decision logic in real time.

[0095] After obtaining the target state of the business state transition, the system will perform the business state transition. Among them, the process of performing the business state transition is the same as the above process of performing the business state transition, and will not be elaborated here.

[0096] When the business status is flowing, the system will pre-define the compensation operations corresponding to each operation and store them in the database. Among them, the compensation operations can be defined according to the actual situation and are not specifically limited here. When some operations cannot be completed during the process of executing the status flow operation, the state machine engine will trigger the pre-defined compensation operation to ensure that the system returns to a consistent state. For example, for the event of calling a number, there is no number in the factory, but the driver shows that there is a number when actually calling the number. Normally, the driver's call for a number will not pass at this time, but due to the time difference resulting in out-of-sync states. For this situation, the business system will pre-define the compensation logic to make the call for a number pass.

[0097] During the process of business status flowing, if an event keeps triggering failures, the system will mark this event as a dead letter event, indicating that the state machine cannot solve this type of event and requires manual intervention.

[0098] In a possible implementation, when the state machine is triggered by a correct event (this trigger event is a legal event configured for the current state), the state machine will normally flow to the next state. Due to the time difference caused by the inconsistent triggering time of the trigger event and the received time, the business data changes during this period. The essence of the above scenario is an out-of-order event. Because the triggering time and the event receiving time are inconsistent, the business data may change during this period, resulting in changes in the state machine context information, making the trigger event and the state machine context not match during the status flow, resulting in abnormal status flow. Therefore, for the above scenario, its essence is also an out-of-order scenario, and the processing process of out-of-order events will also be started. The specific processing process is the same as the above out-of-order event processing process and will not be elaborated here.

[0099] Based on the above processing of out-of-order events, it is ensured that events are not lost, the trigger event can be correctly triggered, and the problem that the business status flow may be abnormal due to the inconsistent event receiving timing and event triggering timing and the possible change of business data is solved.

[0100] When determining that the trigger event is an abnormal event and starting the processing process of abnormal events, the following method can be adopted:

[0101] That is, when processing abnormal events, the system will make the state machine return to the normal state by configuring virtual events.

[0102] Specifically, first, the system will pre-embed points at the error-prone links to obtain various abnormal events, define corresponding virtual events according to the various abnormal events to obtain the various virtual events. At the same time, configure the binding relationship between the virtual events and the abnormal events and the target states through which the virtual events flow, and store them in the database. Among them, the abnormal event refers to an event where the trigger event caused by the user's misoperation is inconsistent with the current state node. The virtual event refers to the corresponding trigger event when processing the abnormal event. And the virtual event can be flexibly configured according to the actual situation, and no specific limitation is made here. Then, when processing the abnormal event, first find the corresponding virtual event from the database according to the configured binding relationship between the virtual event and the abnormal event, and use the found virtual event as the trigger event to be handed over to the state machine engine. The state machine engine will first determine whether the trigger event is the configured virtual event according to the configured virtual event. If it is not the configured virtual event, re-find the corresponding virtual event in the database according to the configured binding relationship between the abnormal event and the virtual event; if it is determined to be a virtual event, at this time it means that the state transition to the specified target state is legal, and a virtual state transition sequence can be created for the business state to flow. Among them, the virtual state transition sequence can be understood as a dynamic state transition template. That is to say, when creating the virtual state transition sequence, a state transition process template that transitions from the state corresponding to the virtual event to the specified target state will be constructed according to the configuration information predefined by the business system. Its construction method is the same as that of the state process template, and no more details will be elaborated here. When performing the state transition, the corresponding process instance will complete the state transition according to the created virtual state transition sequence.

[0103] When performing the state transition according to the created virtual state transition sequence, the virtual state transition sequence will transition the state where the current virtual event is located to the specified target state. Because the business system has pre-configured the events corresponding to the states and defined the binding relationship between the events and the operations, when performing the business state transition according to the virtual state transition sequence, the operation list of the virtual event defined by the business system will also be called and traversed for execution. After the execution is completed, an event mark will be made, and then a logical operation will be performed to determine whether it meets the transition condition. If it meets the condition, the state transition will be performed, so that the state machine can transition to the specified target state. The specific state transition method is the same as the method of performing the business state transition above, and no more details will be elaborated here.

[0104] By configuring the virtual event, the business state in the abnormal situation can be corrected back to the correct state, ensuring the consistency of the business data.

[0105] Furthermore, refer to Figure 2As shown, when the system performs business state conversion, it often encounters the situation of querying the business state and business data at any time. When querying the current business state, after the business system receives a request to query the current business state, it will call the query interface of the state machine engine according to the business information (waybill number, that is, the Figure 2 business key shown) to obtain the current business state and the corresponding front-end configuration information in the current state, and return the current business state and the corresponding front-end configuration information in the current state to the system front-end. The system front-end renders the page according to the returned configuration information, and finally obtains the current business state and related business data. Moreover, if it is temporarily necessary to adjust the display of a certain state under a certain business type, it only needs to be modified in the configuration information defined by the business system, without modifying the code or releasing a version, reducing the development and operation and maintenance costs.

[0106] Finally, after the business state flows to the end node of the corresponding process template, the corresponding state process instance ends its life cycle and is no longer called. If the current state instance is called subsequently, the system will mark it as an illegal call.

[0107] Therefore, the present disclosure provides a method for choreographing and processing business state transitions, which specifically includes: when receiving a trigger event, querying a state machine process instance corresponding to the waybill event request according to the trigger event, where the state machine process instance is created based on the initial business waybill, and the process instance contains the business state information of the business waybill; obtaining the current state of the waybill according to the state machine process instance, and querying a process template corresponding to the trigger event; where the process template contains state machine rule configuration information; obtaining an operation list corresponding to the trigger event according to the process template, and traversing and executing each operation according to the operation list, thereby completing the state transition of the trigger event. The above processing method completes the business state transition by using a stateful state machine and a stateless state machine in combination, realizing both the intuitive display of the current business state and not occupying too much system memory to process the business state transition. The present disclosure uses the created state process instance as the stateful state machine and the state process template as the stateless state machine, so that during the business state transition process, the state process instance only needs to call the corresponding state process template and complete the business state transition according to the state process template. It reduces the complexity of accessing the business system and improves the performance of the state transition system at the same time.

[0108] <Apparatus Embodiment>

[0109] Figure 3 Fig. shows a schematic block diagram of a device for choreographing and processing business state transitions according to an embodiment of the present disclosure. As Figure 3As shown, the device 100 includes: a process instance query module 110, a process template query module 120, and a business status transfer module 130. Among them, the process instance query module 110 is configured to query the corresponding state machine process instance according to the trigger event when receiving the trigger event. The state machine process instance is created based on the initial business waybill, and the business status information of the business waybill is included in the process instance. The process template query module 120 is configured to obtain the current status of the waybill according to the state machine process instance and query the process template corresponding to the trigger event. The process template includes state machine rule configuration information. The business status transfer module 130 is configured to obtain the operation list corresponding to the trigger event according to the process template and traverse and execute each operation according to the operation list, thereby completing the status transfer of the trigger event.

[0110] <Device Embodiment>

[0111] Figure 4 FIG. shows a schematic block diagram of a business status transfer orchestration processing device according to an embodiment of the present disclosure. As Figure 4 shown, the business status transfer orchestration processing device 200 includes: a processor 210 and a memory 220 for storing executable instructions executable by the processor 210. Among them, the processor 210 is configured to implement the business status transfer orchestration processing method described in any one of the foregoing when executing the executable instructions.

[0112] Here, it should be noted that the number of processors 210 can be one or more. At the same time, in the business status transfer orchestration processing device 200 of the embodiment of the present disclosure, an input device 230 and an output device 240 may further be included. Among them, the processor 210, the memory 220, the input device 230, and the output device 240 may be connected through a bus or in other ways, which is not specifically limited here.

[0113] The memory 220, as a computer-readable storage medium, can be used to store software programs, computer-executable programs, and various modules, such as: the programs or modules corresponding to the business status transfer orchestration processing method of the embodiment of the present disclosure. The processor 210 executes various functional applications and data processing of the business status transfer orchestration processing device 200 by running the software programs or modules stored in the memory 220.

[0114] The input device 230 can be used to receive input numbers or signals. Among them, the signal can be a key signal related to the user settings and function control of the device / terminal / server. The output device 240 may include a display device such as a display screen.

[0115] The embodiments of the present disclosure have been described above. The above description is exemplary and not exhaustive, and is also not limited to the disclosed embodiments. Many modifications and variations are obvious to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The choice of terms used herein is intended to best explain the principles of the embodiments, practical applications, or technical improvements in the market, or to enable other ordinary skilled persons in the art to understand the embodiments disclosed herein.

Claims

1. A method for processing the transfer of service status, characterized in that, Including: When a trigger event is received, query the corresponding state machine process instance according to the trigger event, where the state machine process instance is created based on an initial business waybill, and the process instance contains the business status information of the business waybill; Obtain the current status of the waybill according to the state machine process instance, and query the process template corresponding to the trigger event; where the process template contains state machine rule configuration information; The state machine rule configuration information refers to the association relationship among the business status, the event, and the operations associated with each event; that is, the business status information, the trigger events configured under each business status, and the operations associated with each trigger event are recorded in the state process template; Obtain the operation list corresponding to the trigger event according to the state machine rule configuration information recorded in the process template, and traverse and execute each operation according to the operation list, thereby completing the state transition of the trigger event.

2. The method according to claim 1, wherein When querying the corresponding state machine process instance according to the trigger event, it includes: Extract the waybill information from the trigger event; Query the state machine process instance according to the waybill information.

3. The method according to claim 1, wherein After obtaining the current status of the waybill according to the state machine process instance and querying the process template corresponding to the trigger event, it further includes: Judge whether the trigger event matches the current status of the waybill; When it is judged that the trigger event matches the current status of the waybill, execute the step of obtaining the operation list corresponding to the trigger event according to the state machine rule configuration information recorded in the process template.

4. The method according to claim 1, wherein After obtaining the operation list corresponding to the trigger event according to the process template and traversing and executing each operation according to the operation list, it further includes: Judge whether the state transition condition is satisfied; When it is judged that the state transition condition is satisfied, trigger the next trigger event.

5. The method according to claim 4, wherein When judging whether the state transition condition is satisfied, it includes: Record the successful execution of the current event into redis and mysql, then obtain the execution status of other events in the current status from redis, and mark the execution status of other events; Then perform a logical operation according to the configured transition expression to obtain a boolean value; When the boolean value is true, it indicates that the state transition condition is satisfied.

6. The method according to claim 3, wherein When judging whether the trigger event matches the current status of the waybill, it further includes: When it is judged that the trigger event does not match the current status of the waybill, determine the trigger event; When it is determined that the trigger event is an out-of-order event, start the operation of the out-of-order event handling process; Wherein, the out-of-order event is an event in which the current trigger node is inconsistent with the configured trigger node among the events configured for the business waybill.

7. The method according to claim 6, wherein The out-of-order event handling process includes: Persist the out-of-order event into a special out-of-order event table; Then mark the out-of-order event in the out-of-order event table as the "skipped" state, and maintain an ordered queue of skipped events in memory; Capture the context of the current state machine of the out-of-order event according to the out-of-order event; Evaluate the priority of the out-of-order event according to the evaluation factors; wherein, the evaluation factors include at least one of the importance of the event type, the chronological order of the event occurrence, and the degree of business impact.

8. The method according to claim 6, wherein When it is determined that the trigger event is an abnormal event, an abnormal prompt is issued. Wherein, the abnormal event is an event triggered by a user's incorrect operation.

9. A service status transfer and orchestration processing device, characterized in that, It includes: A process instance query module, configured to, when receiving a trigger event, query a corresponding state machine process instance according to the trigger event, wherein the state machine process instance is created based on an initial business waybill, and the process instance contains business status information of the business waybill. A process template query module, configured to obtain the current status of the waybill according to the state machine process instance, and query a process template corresponding to the trigger event; wherein, the process template contains state machine rule configuration information. The state machine rule configuration information refers to: the association relationship among the business status, the event, and the operations associated with each event; that is, the business status information is recorded in the state process template, as well as the trigger events configured under each business status, and the operations associated with each trigger event. A business status transfer module, configured to obtain an operation list corresponding to the trigger event according to the process template, and traverse and execute each operation according to the operation list, thereby completing the status transfer of the trigger event.

10. A service status transfer and orchestration processing device, characterized in that, It includes: A processor; A memory for storing instructions executable by the processor; Wherein, the processor is configured to implement the method according to any one of claims 1 to 8 when executing the executable instructions.

Citation Information

Patent Citations

  • State machine system, transaction state management method and bank transaction system

    CN116977048A