Task processing method, device, electronic device, storage medium and program product
By responding to task trigger events in task processing, obtaining and determining task status, and determining transfer logic from the target state machine, the performance loss problem caused by the redundant state of state machines is solved, and efficient task processing is achieved.
Patent Information
- Application Number
- CN202210028748.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-11
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2042-01-11
AI Technical Summary
When using a stateful state machine to handle tasks, the state chance is redundant in its own memory object, resulting in the state machine instance rebuilding according to the task object identification, which has serious performance loss.
By responding to the task trigger event of the pending task, obtain task execution information, determine the current task status, and obtain the target state machine according to the task type, determine the target transfer logic from it, and trigger the execution of the pending task to obtain the processing result.
There is no need to store the current task state in the state machine, which avoids the performance overhead of repeatedly building the state machine and improves the efficiency of task processing.
Smart Images

Figure CN114371939B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer application technology, and in particular to a task processing method, task processing apparatus, electronic device, computer-readable storage medium, and computer program product. Background Art
[0002] In server-side task code, state changes in the task domain model are typically written in a flow-like manner, filled with conditional statements (if else) and other change code, resulting in non-convergent state changes in the task model and an inability to clearly express them. Therefore, this may lead to the following two problems: (1) Maintainability issues. For example, when new developers review the code, they may not be able to clearly understand the flow relationships of the task model and need to read the entire code to understand it. (2) Readability issues. When task code is modified, the scope of impact of the modified points needs to be carefully analyzed.
[0003] State machines are a good modeling tool for solving the above problems. By pre-defining the states, atomic response actions, and corresponding transition target states, they enable the visualization and monitoring of the life flow of complex task scenarios. Summary of the Invention
[0004] This disclosure provides a task processing method, apparatus, electronic device, computer-readable storage medium, and computer program product to at least solve the problem that when using a stateful state machine for task processing, the state machine redundantly stores states in its own memory object, resulting in significant performance degradation as the state machine instance needs to be reconstructed based on the task object identifier each time a task is executed. The technical solution of this disclosure is as follows:
[0005] According to a first aspect of the present disclosure, a task processing method is provided, which, in response to a task triggering event of a task to be processed, acquires task execution information of the task to be processed; determines the current task state of the task to be processed based on the task execution information; acquires a corresponding target state machine based on the task type of the task to be processed; determines a corresponding target transition logic from the target state machine based on the current task state and the task triggering event; and triggers the execution of the task to be processed based on the target transition logic to obtain a task processing result.
[0006] In one exemplary embodiment of this disclosure, the method further includes: obtaining a set of task types; the set of task types includes multiple candidate task types; selecting a candidate task type from the set of task types and determining multiple task states corresponding to the candidate task type; determining a transition trigger event and state transition logic between the multiple task states, and generating an initial task state machine based on the multiple task states, the transition trigger event and the state transition logic; and generating a task state machine based on the initial task state machine.
[0007] In one exemplary embodiment of this disclosure, generating a task state machine based on the initial task state machine includes: determining a distributed task system for task processing and determining a distributed task processing framework corresponding to the distributed task system; adding the initial task state machine to the distributed task processing framework to generate the task state machine.
[0008] In one exemplary embodiment of this disclosure, the distributed task processing framework includes a task processing class. Adding the initial task state machine to the distributed task processing framework to generate the task state machine includes: determining a state machine identifier for the initial task state machine and adding the state machine identifier to the task processing class; obtaining lifecycle events of the initial task state machine and determining the event content of the lifecycle events; adding event annotation information to the lifecycle events according to the event content to generate task processing events; generating the task state machine based on the task processing class and the task processing events; the task processing event has a corresponding task processor.
[0009] In one exemplary embodiment of this disclosure, before obtaining the lifecycle events of the initial task state machine, the method further includes: determining lifecycle processing logic for task processing; determining basic processing events and extended processing events based on the lifecycle processing logic; and generating the lifecycle events based on the basic processing events and the extended processing events.
[0010] In one exemplary embodiment of this disclosure, after generating the task processing event, the method further includes: performing event filtering processing on multiple task processing events according to the event annotation information to obtain at least one event to be executed; sorting the event to be executed to obtain an event sorting result, so as to execute the event to be executed according to the event sorting result.
[0011] In one exemplary embodiment of this disclosure, the step of triggering the execution of the task to be processed according to the target transfer logic to obtain a task processing result includes: obtaining a lifecycle event corresponding to the task to be processed; determining a corresponding target transfer event from the lifecycle event according to the target transfer logic; and calling a corresponding target task processor according to the target transfer event to determine the task processing result based on the execution result of the target task processor.
[0012] In one exemplary embodiment of this disclosure, the target transfer event includes a trigger transfer event. The step of invoking the corresponding target task processor according to the target transfer event to determine the task processing result based on the execution result of the target task processor includes: invoking the task transfer processor according to the trigger transfer event; performing state transfer processing on the task to be processed through the task transfer processor to obtain a state transfer result, and using the state transfer result as the task processing result.
[0013] In one exemplary embodiment of this disclosure, the target transfer event includes an abnormal transfer event. Invoking a corresponding target task processor based on the target transfer event to determine the task processing result based on the execution result of the target task processor includes: invoking an abnormal transfer processor based on the abnormal transfer event; obtaining the abnormal transfer result obtained by the abnormal transfer processor for the task to be processed; and using the abnormal transfer result as the task processing result.
[0014] In one exemplary embodiment of this disclosure, the target transfer event includes a non-transfer event, and the method further includes: determining a state transfer failure result based on the non-transfer event, and using the state transfer failure result as the task processing result.
[0015] According to a second aspect of the present disclosure, a task processing apparatus is provided, comprising: an execution information acquisition module configured to acquire task execution information of the task to be processed in response to a task triggering event; a task state determination module configured to determine the current task state of the task to be processed based on the task execution information; a target logic determination module configured to acquire a corresponding target state machine based on the task type of the task to be processed, and determine a corresponding target transition logic from the target state machine based on the current task state and the task triggering event; and a task processing module configured to trigger the execution of the task to be processed based on the target transition logic to obtain a task processing result.
[0016] In one exemplary embodiment of this disclosure, the task processing device further includes a state machine construction module, which is configured to perform: obtaining a task type set; the task type set includes multiple candidate task types; selecting a candidate task type from the task type set and determining multiple task states corresponding to the candidate task type; determining transition trigger events and state transition logic between the multiple task states, and generating an initial task state machine based on the multiple task states, the transition trigger events, and the state transition logic; and generating a task state machine based on the initial task state machine.
[0017] In one exemplary embodiment of this disclosure, the state machine construction module includes a state machine construction unit, which is configured to perform: determining a distributed task system for task processing and determining a distributed task processing framework corresponding to the distributed task system; adding the initial task state machine to the distributed task processing framework to generate the task state machine.
[0018] In one exemplary embodiment of this disclosure, the state machine construction unit includes a state machine construction subunit, which is configured to perform: determining the state machine identifier of the initial task state machine and adding the state machine identifier to the task processing class; obtaining the lifecycle events of the initial task state machine and determining the event content of the lifecycle events; adding event annotation information to the lifecycle events according to the event content to generate task processing events; generating the task state machine based on the task processing class and the task processing events; the task processing events having corresponding task processors.
[0019] In one exemplary embodiment of this disclosure, the state machine construction module further includes an event generation unit configured to perform: determining lifecycle processing logic for task processing; determining basic processing events and extended processing events based on the lifecycle processing logic; and generating the lifecycle events based on the basic processing events and the extended processing events.
[0020] In one exemplary embodiment of this disclosure, the state machine construction module further includes an event sorting unit, which is configured to perform: event filtering processing on multiple task processing events according to the event annotation information to obtain at least one event to be executed; sorting the event to be executed to obtain an event sorting result, so as to execute the event to be executed according to the event sorting result.
[0021] In one exemplary embodiment of this disclosure, the task processing module includes a task processing unit configured to perform: acquiring a lifecycle event corresponding to the task to be processed; determining a corresponding target transfer event from the lifecycle event according to the target transfer logic; and invoking a corresponding target task processor according to the target transfer event to determine the task processing result based on the execution result of the target task processor.
[0022] In one exemplary embodiment of this disclosure, the task processing unit includes a first processing subunit, which is configured to perform: invoking a task transfer processor according to the triggered transfer event; performing state transfer processing on the task to be processed through the task transfer processor to obtain a state transfer result, and using the state transfer result as the task processing result.
[0023] In one exemplary embodiment of this disclosure, the task processing unit further includes a second processing subunit, which is configured to perform the following: invoking an exception transfer processor according to the exception transfer event; obtaining the exception transfer result obtained by the exception transfer processor for the task to be processed; and using the exception transfer result as the task processing result.
[0024] In one exemplary embodiment of this disclosure, the task processing unit further includes a third processing subunit, which is configured to perform the following: determining a state transition failure result based on the non-transfer event, and using the state transition failure result as the task processing result.
[0025] According to a third aspect of this disclosure, an electronic device is provided, comprising: a processor; and a memory for storing processor-executable instructions; wherein the processor is configured to execute instructions to implement the task processing method described in any of the preceding claims.
[0026] According to a fourth aspect of this disclosure, a computer-readable storage medium is provided, wherein when the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the task processing method described in any of the preceding claims.
[0027] According to a fifth aspect of the present disclosure, a computer program product is provided, including a computer program / instructions, characterized in that the computer program / instructions, when executed by a processor, implement the task processing method described in any one of the above embodiments.
[0028] The technical solutions provided by the embodiments of the present disclosure bring at least the following beneficial effects:
[0029] The task processing method disclosed herein determines the current task state of the task to be processed based on the task execution information. Since the current task state of the task to be processed does not need to be stored in the state machine, the task state machine does not need to be reconstructed for different objects of the same task, which greatly reduces the performance overhead of repeated construction.
[0030] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure. Attached Figure Description
[0031] The accompanying drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute an improper limitation of the present disclosure.
[0032] Figure 1 This is a flowchart illustrating a task processing method according to an exemplary embodiment.
[0033] Figure 2 This is a flowchart illustrating a task state machine generation method according to an exemplary embodiment.
[0034] Figure 3 This is a flowchart illustrating an example of adding a task state machine to a distributed task processing framework.
[0035] Figure 4 This is a flowchart illustrating the entire lifecycle events of a task to be processed according to an exemplary embodiment.
[0036] Figure 5 This is a flowchart illustrating, according to an exemplary embodiment, a process of triggering the execution of a pending task based on a target transfer logic to obtain an execution result.
[0037] Figure 6 This is a block diagram illustrating a task processing apparatus according to an exemplary embodiment.
[0038] Figure 7 A block diagram of an electronic device according to an exemplary embodiment of the present disclosure is shown schematically. Detailed Implementation
[0039] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.
[0040] It should be noted that the terms "first," "second," and the like in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or precedence. It should be understood that the numbers used in this manner are interchangeable where appropriate so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure as detailed in the appended claims.
[0041] To address the state change problem in task domain models, state machines can achieve visualized and monitorable lifecycles of complex task scenarios by pre-defining states, atomic response actions, and corresponding transition target states. Currently, commonly used open-source state machine frameworks include: stateless4j, squirrel-foundation, spring-statemachine, and cola-statemachine. In distributed systems, the main considerations for state machine frameworks are as follows: (1) lifecycle extension capability; (2) configuration method; (3) whether it supports distributed stateless / multithreaded systems; and (4) whether it supports Spring extended lifecycles.
[0042] Analysis of the four commonly used state machine frameworks reveals that Stateless4j, Squirrel-Foundation, and Spring-StateMachine are all state machines with stateful models, where redundant states are stored in their own memory objects. In distributed, multi-threaded concurrent models, this necessitates repeatedly constructing the state machine based on the task model identifier for each execution, resulting in significant performance overhead. Furthermore, Spring-StateMachine lacks Spring integration capabilities and lifecycle extension points, making task integration and extension difficult.
[0043] Based on this, according to embodiments of the present disclosure, a task processing method, a task processing apparatus, an electronic device, a computer-readable storage medium, and a computer program product are proposed.
[0044] In this article, it is important to understand that the terms used, such as Final State Machine (FSM), refer to a machine that is in one of a finite set of states at any given time. When it receives an input character, it transitions from the current state to another state, or remains in the current state. Any FSM can be described using a state transition graph, where nodes represent states in the FSM and directed weighted edges represent state changes upon receiving an input character.
[0045] Figure 1 This is a flowchart illustrating a task processing method according to an exemplary embodiment, such as... Figure 1 As shown, the task processing method is used in a server. This exemplary embodiment illustrates the application of this method to a distributed server, including the following steps:
[0046] In step S110, in response to the task triggering event of the task to be processed, the task execution information of the task to be processed is obtained.
[0047] In some exemplary embodiments of this disclosure, the task to be processed can be a specific task to be processed in a distributed task system. Taking an online shopping scenario as an example, the order flow generated during a user's selection of items can be considered a task to be processed. Task information can be specific information corresponding to the task to be processed. Current state can be the specific state corresponding to the current task to be processed. Task triggering event can be a triggering event corresponding to a change in the specific state of the task to be processed. For example, in an online shopping scenario, the task triggering event can be a user's click operation on the "Submit Order" control. Task execution information can be relevant information on which subsequent processing operations are based for the task to be processed. Task execution information can include basic task information, which can be specific information used to distinguish the task to be processed from other tasks. For example, basic task information can include a task identifier, which can be used to uniquely identify a specific task.
[0048] During task processing, a computer can determine pending tasks based on task trigger events. For example, pending tasks can include actual business transactions from various industries. By inputting these transactions into the computer, it can generate specific pending tasks for processing according to corresponding logic. For a given pending task, a user can perform relevant user actions. Upon receiving these actions, a corresponding task trigger event is generated. For example, in a shopping scenario, when a user selects items and prepares to click the payment button, clicking the payment button generates a corresponding task trigger event. In other words, the task trigger event can be the event triggered by the user clicking the payment button. Responding to the task trigger event, the computer can obtain the task execution information, which may include the current time and basic task information. For example, the current order status might be unpaid; the current time might be "2021-01-01 00:00:00"; and the basic task information might include the order number and the buyer's user ID.
[0049] In step S120, the current task status of the task to be processed is determined based on the task execution information.
[0050] In some exemplary embodiments of this disclosure, the current task state can be the current state of the task to be processed. In a shopping scenario, the current task state can be the current processing state of a particular order.
[0051] After obtaining the task execution information of the pending task, the current task status can be obtained from the task execution information. For example, in an online shopping scenario, when a user has selected items and is ready to pay, the current order status is "unpaid," which can be taken as the current task status.
[0052] In step S130, the corresponding target state machine is obtained according to the task type of the task to be processed, and the corresponding target transition logic is determined from the target state machine according to the current task state and the task triggering event.
[0053] In some exemplary embodiments of this disclosure, the task type can be a specific type to which the task to be processed belongs. The target state machine can be the state machine used when processing the task to be processed; in this embodiment, the target state machine is a stateless state machine. A stateless state machine can mean that the state machine is a one-time operation, does not need to save data, and is thread-safe. The target transition logic can be the state transition logic used when processing the task to be processed. For example, the target transition logic can be the logic corresponding to when the task to be processed undergoes a state transition to perform a corresponding action. The state transition logic can be a State Transform Diagram (STD) of a stateless state machine, representing a behavioral model. The STD represents the behavior of the system by describing the task state and the events that cause the task state transition, indicating which actions (e.g., data processing) will be performed as a result of a specific event.
[0054] In practical task processing, there are various different task scenarios, such as online shopping, online learning, and appointment booking. Therefore, a task processing system can contain various types of tasks to be processed. After obtaining the current task status of the tasks to be processed, the task type can be determined, and the target state machine corresponding to the task can be obtained based on the task type. For example, when the task type is a shopping task, the obtained target state machine is a state machine containing the shopping task processing logic.
[0055] Since the task processing model defines the state transition logic used during task processing, after determining the current task state and task triggering event of the task to be processed, the target transition logic used to process the task can be determined from the target state machine based on the current task state, task triggering event, and basic task information in the task execution information. For example, when a user's payment operation for an order pending payment is received, the current order status of the order can be updated to "Paid, Awaiting Shipment" based on the user's specific operation. The processing logic relied upon in the order status change process is the target transition logic.
[0056] In step S140, the task to be processed is executed according to the target transfer logic to obtain the task processing result.
[0057] In some exemplary embodiments of this disclosure, the task processing result may be the result obtained after processing the task to be processed.
[0058] The task to be processed is then analyzed according to the determined target transfer logic to obtain the corresponding task processing result. Taking a shopping scenario as an example, when a user successfully completes the payment operation, the order status changes from unpaid to paid, a payment success message is returned to the user, and a corresponding paid order is generated. If payment fails for some reason, the order status will not change, and a payment failure message will be returned to the user so that the user can take further action. If an exception occurs during the order payment process, the order status will not change, and a payment exception message will be returned to the user.
[0059] According to the task processing method in this example embodiment, the current task state of the task to be processed is determined based on the task execution information. Since the current task state of the task to be processed does not need to be stored in the state machine, the task state machine does not need to be reconstructed for different objects of the same task, which greatly reduces the performance overhead of repeated construction.
[0060] The task processing method in this example embodiment will be further explained below.
[0061] In one exemplary embodiment of this disclosure, a task type set is obtained; the task type set includes multiple candidate task types; a candidate task type is selected from the task type set, and multiple task states corresponding to the candidate task type are determined; a transition trigger event and state transition logic between multiple task states are determined, and an initial task state machine is generated based on the multiple task states, the transition trigger event and the state transition logic; and a task state machine is generated based on the initial task state machine.
[0062] The task type set can be a collection of multiple candidate task types. Candidate task types can be specific types corresponding to all tasks in the task processing system. Task states can be specific states corresponding to all tasks included in the task processing system. Transition trigger events can be trigger events corresponding to the transition from one task state to another. State transition logic can be the processing logic used by a task to generate a state transition. The initial task state machine can be a state machine generated through state machine definition, and it is not yet associated with a specific task processing framework. The task state machine can be a state machine added to a specific task processing framework. The task state machine can include the relevant control logic for controlling different state transitions of specific tasks. The task state machine can be a stateless state machine, and it does not store information related to specific task instances.
[0063] Since stateful models often store redundant states in their own memory objects, this disclosure provides an implementation scheme that supports stateless state machines. In this embodiment, a stateless redundancy state machine definition is used. (See reference...) Figure 2 , Figure 2 This is a flowchart illustrating a task state machine generation method according to an exemplary embodiment. In step S210, a task type set is obtained; the task type set includes multiple candidate task types. In actual task processing, various specific tasks in different scenarios may be involved. Therefore, all task types involved in task processing can be determined first as candidate task types, and the determined candidate task types are used to generate a task type set.
[0064] In step S220, a candidate task type is selected from the task type set, and multiple task states corresponding to the candidate task type are determined. Since tasks of different candidate task types require their own corresponding task processing logic, when constructing the task state machine, state machine definition operations can be performed on each of the multiple candidate task types in the task type set to generate the corresponding initial task state machine. For example, the candidate task type "shopping" can be selected from the task type set, and an initial task state machine corresponding to the "shopping" task type can be constructed. After selecting a candidate task type from the task type set, multiple task states corresponding to that candidate task type can be determined. Specifically, the implementation code for the state machine definition without state redundancy is as follows:
[0065] public enum States{STATE1,STATE2,STATE3,STATE4}
[0066] The code above indicates that the initial task state machine corresponding to a certain candidate task type contains multiple task states. For example, the code above defines four task states, STATE1 to STATE4.
[0067] In step S230, the transition trigger events and state transition logic between multiple task states are determined, and an initial task state machine is generated based on the multiple task states, transition trigger events, and state transition logic. After determining the multiple task states, the transition trigger events and state transition logic between the multiple task states can be further determined. The specific implementation code is as follows: public enum Events{EVENT1,EVENT2}
[0068] The code above defines transition trigger events between different task states, namely EVENT1 and EVENT2. Taking a shopping scenario as an example, the order status of a shopping order can include pending payment, paid, pending shipment, shipped, in transit, signed for, pending review, etc. Transition trigger events can include user actions such as adding or deleting items, user payment actions, and user order cancellation actions.
[0069] @Data
[0070] public static class Context{
[0071] public String operator="frank";
[0072] public String entityId="123465";
[0073] }
[0074] The code snippet above defines a basic information retrieval class, which can define the operator and instance identifier for retrieving task instances. Taking a shopping scenario as an example, the operator for a certain order can be "frank", and the order ID can be "123465".
[0075] @Bean
[0076] public StateMachine<States,Events,Context> testStateMachine(){
[0077] StateMachineBuilder<States,Events,Context> builder =
[0078] StateMachineBuilderFactory.create();
[0079] builder.externalTransitions()
[0080] .fromAmong(States.STATE1,States.STATE2,States.STATE3)
[0081] .to(States.STATE4)
[0082] .on(Events.EVENT1)
[0083] .whenExpression("context.operator=='frank'")
[0084] .when((AnonymousCondition<States,Events,Context>)context->context.getContext().operator
[0085] .equalsIgnoreCase("frank"))
[0086] .perform(doAction());
[0087] StateMachine<States,Events,Context>stateMachine=builder.newStateMachine(MACHINE_ID);
[0088] return stateMachine;
[0089] }
[0090] The above code indicates that the initial task state machine can have task transition logic between some task states. For example, the initial task state machine can jump from task state 1, task state 2, and task state 3 to task state 4 based on certain state transition conditions and transition trigger event 1. In this task transition logic, the task transition condition can be that the operator is "frank," that is, when the operator is "frank," the transition can be from task state 1, task state 2, or task state 3 to task state 4 based on transition trigger event 1. After determining all task states, transition trigger events, and state transition logic, a task state machine can be generated based on the determined content. In step S240, a task state machine is generated based on the initial task state machine. After defining the initial task state machine, it can be added to a specific task processing framework to generate a task state machine that can process the tasks to be processed. Generating a stateless task state machine in the above way can optimize the maintainability and readability of the code, and subsequent state changes of the state machine can be visualized in the code.
[0091] In one exemplary embodiment of this disclosure, a distributed task system for task processing is determined, and a distributed task processing framework corresponding to the distributed task system is determined; an initial task state machine is added to the distributed task processing framework to generate a task state machine.
[0092] In this context, a distributed task processing system can be a system that uses a distributed system for task processing. A distributed task processing framework can be an engine framework created within a distributed task system to accommodate the complexities of software development and task processing.
[0093] The task state machine in this disclosure can be used in a single-server task processing system as well as in a distributed task processing system. This embodiment discloses a specific implementation scheme for adding an initial task state machine to a distributed task system to perform task processing based on the generated task state machine, thereby solving the problem of severe performance loss caused by repeatedly building state machines in a distributed task processing system. (Reference) Figure 3 , Figure 3 This is a flowchart illustrating the addition of a task state machine to a distributed task processing framework according to an exemplary embodiment. In step S310, a distributed task system for task processing is determined, and the corresponding distributed task processing framework is determined. The distributed task system is determined so that, to better serve the task processing of the distributed task system, a specific distributed task processing framework can be built within it; for example, the distributed task system can use the Spring framework.
[0094] In step S320, the initial task state machine is added to the distributed task processing framework to generate the task state machine. After determining the distributed task processing framework used by the distributed task system, the generated initial task state machine can be added to the distributed task processing framework via injection. Specifically, the following code provides an annotation-based injection implementation.
[0095] StateMachine<FulfillmentStatus,FulfillmentEvent,FulfillmentStateMachineContext> eTicketStateMachine;
[0096] public FulfillResultDTO fulfill(Long orderId){
[0097] FulfillReq request=FulfillReq.newBuilder().setOrderId(orderId).build();
[0098] eTicketStateMachine.fireEventAutoWiredSource(FulfillmentEvent.CREATE_FULFILLMENT_ORDER,request);
[0099] }
[0100] The annotation-based injection method described above allows the defined initial task state machine to be injected into the container of the distributed task processing framework (i.e., the Spring framework) to handle distributed tasks based on the generated task state machine. Alternatively, configuration-based injection can be used to inject the initial task state machine into the Spring framework, generating a corresponding task state machine, which the distributed task system can then use to handle distributed tasks. Adding the initial task state machine to the distributed task processing framework can be done through annotation-based configuration or configuration-based injection; both methods are simple and easy to implement.
[0101] The difference between the stateless state machine and the stateful state machine defined in this disclosure is that when a task state machine change is triggered, each thread in the stateless state machine has a context. This context can be used to obtain the task information of the current task, that is, to obtain the task instance's current task state, current time, task unique identifier, and other task information, instead of being redundant in the state machine model. Therefore, it can effectively solve the problem of huge performance overhead caused by repeatedly building state machines.
[0102] This disclosure provides a simple integration method by distributing the initial task state machine to the task processing framework via annotation-based injection. Furthermore, since the initial task state machine can be generated by injecting it into the distributed task processing framework, distributed functionality, such as distributed monitoring and concurrency control, can be provided when using the task state machine for task processing.
[0103] In one exemplary embodiment of this disclosure, a state machine identifier for an initial task state machine is determined and added to a task processing class; lifecycle events of the initial task state machine are obtained and the event content of the lifecycle events is determined; event annotation information is added to the lifecycle events according to the event content to generate task processing events; a task state machine is generated based on the task processing class and the task processing events; and each task processing event has a corresponding task processor.
[0104] Here, the state machine identifier can be a unique identifier (Identity document, id) corresponding to the initial task state machine. The task processing class can be a reference data type predefined in the distributed task processing framework for task processing. Lifecycle events can be events that the task state machine may generate throughout the entire lifecycle of task processing. Event content can be the specific content corresponding to the lifecycle event, which may include the specific event type. Event annotation information can be the detailed annotation content corresponding to the lifecycle event; this annotation content can be read during compilation, class loading, and runtime, and corresponding processing can be performed to facilitate information supplementation or deployment by other tools. The task processor can be a processor that executes specific task processing steps.
[0105] refer to Figure 4 , Figure 4 This is a flowchart illustrating the entire lifecycle events of a task to be processed according to an exemplary embodiment. The entire lifecycle of a stateless state machine may include... Figure 4The process nodes in the framework, and the way the task party can use, is to define the lifecycle events of the initial task state machine through simple annotation injection. Specifically, this includes: annotating the task processing class within the distributed task processing framework with a state machine identifier; for example, the task processing class can be annotated with `WithStateMachine id` as the state machine ID. Since a state machine can correspond to multiple lifecycle events, the event content of each lifecycle event is determined. Based on the specific event content, the event annotation information corresponding to each lifecycle event can be determined, and annotations can be added to the corresponding lifecycle events to generate the corresponding task processing events. For the determined task processing events, the corresponding task processor can be determined; that is, each task processing event has its own corresponding task processor, which is used to execute this task processing event. After generating the task processing events, task state machine 420 can be generated based on the task processing class and the task processing events. Specifically, the specific method for determining the task processor is as follows:
[0106] @WithStateMachine
[0107] static class HandlerBean{
[0108] @SourceStateBuilder
[0109] @Order(value=10)
[0110] public Teststates sourcestateBuilderl(ExecutionStateContext<TestStates,TestEvents,MachineContext> statecontext){…}
[0111] @OnTransitionBegin
[0112] @Order(value=10)
[0113] public void OnTransitionBeginI(ExecutionStateContext<Teststates,TestEvents,MachineContext> statecontext){...}
[0114] The annotation-based injection approach for task handlers allows the application to scan for corresponding annotations during startup using a distributed task processing framework (such as the Spring framework) and register them in the task state machine. Furthermore, when a task event is triggered, the corresponding task handler can be activated based on the pre-configured state machine flow, and the task processing model will then perform the appropriate processing operations at the task layer.
[0115] In one exemplary embodiment of this disclosure, a lifecycle processing logic for task processing is determined, and basic processing events and extended processing events are determined based on the lifecycle processing logic; lifecycle events are generated based on the basic processing events and extended processing events.
[0116] The lifecycle processing logic can be any processing logic involved in the entire task processing lifecycle. Basic processing events can be processing events determined based on the basic task processing flow. Extended processing events can be processing events extended from the current task processing based on the specific needs of the task processing.
[0117] Continue to refer Figure 4 Throughout the entire lifecycle of task processing, the process of task state changes can include multiple logical processing nodes such as information acquisition nodes, normal transfer processing nodes, non-transfer nodes, and abnormal transfer nodes. For a task to be processed, which can be a specific instance of a task processing model, specifically, after the task to be processed is determined through task entry point 410, in step S401, the current task state, triggering transfer event, and context (i.e., task execution information) of the task to be processed are determined, and this task information is sent to the task state machine 420. The task state machine 420 will then proceed with subsequent processing based on the specific task information.
[0118] Specifically, in step S402, after obtaining the task information of the task to be processed and before performing task state transition processing, if some distributed tasks correspond to pre-transition processing logic, the pre-transition processing event corresponding to the pre-transition processing logic can be determined. The pre-transition processing event can be considered an extended processing event; for example, it may include generating a task processing log file. The pre-transition processing event is triggered by the pre-transition task processor, and the task processing model 430 performs the relevant task-level processing flow.
[0119] In step S403, the target transfer logic is determined based on the acquired task information, such as the current task state, the triggered transfer event, and the context, and state transfer processing is performed. Specifically, in steps S404 and S405, the task to be processed is executed according to the normal state transfer logic to process the task. The task processing event that normally performs state transfer can be determined as the target transfer event. The execution of the target transfer event will be carried out through the (execution transfer) task transfer processor and the task transfer completion processor, and the execution result will be fed back to the task processing model 430.
[0120] In step S406, if no state transition logic corresponding to the task to be processed is found according to the task processing model, that is, an untransitioned event can be defined during the task processing process. The untransitioned event is triggered by the task untransition processor and the processing result is sent to the task processing model 430. In step S407, during the task processing, an abnormal handling situation may occur. For this situation, an abnormal transition event can be defined. The abnormal transition event can be triggered by the task transition abnormal processor and the processing result is sent to the task processing model 430. Therefore, the above-mentioned acquisition of task information, target transition event, untransitioned event, and abnormal transition event can all be used as basic processing events in the lifecycle.
[0121] In addition, for task processing, other downstream processing events can be added throughout the lifecycle. Both pre-transfer processing events and downstream processing events can be defined as extended processing events. The identified basic processing events and extended processing events are collectively considered as lifecycle events.
[0122] In one exemplary embodiment of this disclosure, multiple task processing events are filtered based on event annotation information to obtain at least one event to be executed; the events to be executed are sorted to obtain an event sorting result, and the event to be executed is executed according to the event sorting result.
[0123] The events to be executed can be events that are related to the task processing. The event sorting result can be the result of sorting the processed events according to their priority.
[0124] After adding a state machine identifier to the task processing class, the generated multiple task processing events can be further filtered based on event annotation information to select the events that need to be processed and designated as pending events. If multiple pending events are identified, their event priorities are obtained, and the pending events are sorted according to their priorities to obtain a sorting result. The pending events are then executed based on this sorting result for task processing. This event determination method ensures rich extension points when integrating the state machine framework. For example, custom processing schemes can be defined for multiple lifecycle stages: before, during, after, and after a task state transition, with a controllable extension order. Furthermore, this is supported by configuring annotations on the Spring framework's handlers, making task code integration simple.
[0125] In one exemplary embodiment of this disclosure, a lifecycle event corresponding to the task to be processed is obtained; a corresponding target transfer event is determined from the lifecycle event according to the target transfer logic; and the corresponding target task processor is invoked according to the target transfer event to determine the task processing result based on the execution result of the target task processor.
[0126] The target transition event can be a specific event corresponding to a state transition of the task to be processed. The task processor can be a processor used to perform specific task processing on the task to be processed. The execution result can be the result obtained after calling and executing the task processor.
[0127] refer to Figure 5 , Figure 5 This is a flowchart illustrating, according to an exemplary embodiment, a process of triggering the execution of a pending task based on target transfer logic to obtain an execution result. In step S510, the lifecycle event corresponding to the pending task is obtained. In step S520, the corresponding target transfer event is determined from the lifecycle events based on the target transfer logic. The target transfer logic can include normal transfer logic, non-transfer logic, and abnormal transfer logic, such as normal transfer logic corresponding to a trigger transfer event, non-transfer logic corresponding to a non-transfer event, and abnormal transfer logic corresponding to an abnormal transfer event. In step S530, the corresponding target task processor is invoked based on the target transfer event, and the task processing result is determined based on the execution result of the target task processor. A specific target transfer event can invoke a corresponding task processor to process the pending task, obtain the execution result of the task processor, and determine the task processing result based on the execution result of the task processor. (Continue to refer to...) Figure 4In step S408, after the task transfer process is completed, the task transfer processor will return the execution result. In step S409, based on the returned execution result, the transferred task state can be returned to the task entry point 410 to complete the entire task event processing. Since different trigger transfer events correspond to task processors, when a task event is triggered, the corresponding task processor can be triggered according to the pre-configured state machine flow to obtain the corresponding execution result.
[0128] In one exemplary embodiment of this disclosure, a task transfer processor is invoked based on a trigger transfer event; the task transfer processor performs state transfer processing on the task to be processed to obtain a state transfer result, and the state transfer result is used as the task processing result.
[0129] The triggering event can be the event that triggers a state transition in the pending task. The task transition processor can be the processor used to process the task state transition when the pending task undergoes a state transition. The state transition result can be the result obtained after the state transition is processed by the task transition processor.
[0130] When the identified target transition event is a trigger transition event, the task transition processor corresponding to the trigger transition event can be invoked. The task transition processor can perform state transition processing on the task to be processed according to the state transition logic in the trigger transition event, obtain the corresponding state transition result, and use the state transition result as the task processing result. For example, in a shopping scenario, after a user clicks to pay, the order status can change from unpaid to paid. After obtaining the state transition result, the task processing result can be determined based on the state transition result. For example, when the order status changes to paid, the user can be notified that payment has been successful, and the corresponding paid order can be displayed.
[0131] In one exemplary embodiment of this disclosure, an abnormal transfer processor is invoked based on an abnormal transfer event; the abnormal transfer result obtained by the abnormal transfer processor for the task to be processed is obtained, and the abnormal transfer result is used as the task processing result.
[0132] Here, an exception transition event can be an event corresponding to exception handling during the task state transition process of the task to be processed. An exception transition processor can be a processor used to handle exception jumps during the task state transition process of the task to be processed. An exception transition result can be the result obtained by handling the exception during the state transition process through the exception transition processor.
[0133] When the identified target transition event is an abnormal transition event, the corresponding abnormal transition handler can be invoked. The abnormal transition handler can then perform abnormal transition processing on the task to be processed based on the specific abnormal information in the triggering transition event, obtaining the corresponding abnormal state transition result. For example, in a shopping scenario, if a user clicks to pay but the order fails due to a network error or application malfunction, and the current reason for the error is identified as an abnormal state transition result, this result can be used as the task processing result. For instance, if an order encounters a network error during payment but the order status remains unchanged, the order that did not undergo a state transition, along with a message indicating a network error, can be displayed to the user as the task processing result. The user can then perform corresponding actions based on the message.
[0134] In one exemplary embodiment of this disclosure, a state transition failure result is determined based on a non-transition event, and the state transition failure result is used as the task processing result.
[0135] Among them, the state transition failure result can be the failure result corresponding to the task to be processed not undergoing a task state transition.
[0136] When the identified target transition event is a non-transition event, the task transition processing will be unable to find a corresponding handler. In this case, the state transition failure result corresponding to the non-transition event can be determined, and this failure result can be used as the task processing result. For example, in a shopping scenario, after a user clicks to pay, the order fails to be paid successfully due to insufficient payment account balance, incorrect payment password, or changes in order information, and no state transition from unpaid to paid occurs. In this case, the state transition failure result can be used as the task processing result. For example, a prompt can be returned to the payer indicating insufficient balance, incorrect password, or the need to reorder, prompting the user to perform the payment operation again.
[0137] In summary, the task processing method disclosed herein responds to the task triggering event of a task to be processed, obtains the task execution information of the task to be processed, determines the current task state of the task to be processed based on the task execution information, obtains the corresponding target state machine based on the task type of the task to be processed, determines the corresponding target transition logic from the target state machine based on the current task state and the task triggering event, and triggers the execution of the task to be processed based on the target transition logic to obtain the task processing result. On the one hand, determining the current task state of the task to be processed based on the task execution information eliminates the need to store the current task state in the state machine, thus avoiding the need to repeatedly construct the task state machine for different objects of the same task, greatly reducing the performance overhead of repeated construction. On the other hand, in the distributed task processing framework, it can be accessed simply through annotation-based configuration to handle the processing logic of the task state machine, making the access method simple and easy to implement. Furthermore, by customizing the lifecycle events of task processing, it can be ensured that the task has rich extension points when accessing the state machine framework, and custom processing schemes can be defined in multiple lifecycles.
[0138] Figure 6 This is a block diagram of a task processing apparatus according to an exemplary embodiment. (Refer to...) Figure 6 The task processing device 600 includes: an execution information acquisition module 610, a task status determination module 620, a target logic determination module 630, and a task processing module 640.
[0139] The execution information acquisition module 610 is configured to execute a task trigger event in response to a task to be processed, and acquire the task execution information of the task to be processed.
[0140] The task status determination module 620 is configured to determine the current task status of the task to be processed based on the task execution information.
[0141] The target logic determination module 630 is configured to obtain the corresponding target state machine based on the task type of the task to be processed, and determine the corresponding target transition logic from the target state machine based on the current task state and the task triggering event.
[0142] The task processing module 640 is configured to execute pending tasks based on target transfer logic to obtain task processing results.
[0143] In one exemplary embodiment of this disclosure, the task processing apparatus 600 further includes a state machine construction module, which is configured to perform: obtaining a task type set; the task type set includes multiple candidate task types; selecting a candidate task type from the task type set and determining multiple task states corresponding to the candidate task type; determining transition trigger events and state transition logic between the multiple task states, and generating an initial task state machine based on the multiple task states, transition trigger events and state transition logic; and generating a task state machine based on the initial task state machine.
[0144] In one exemplary embodiment of this disclosure, the state machine construction module includes a state machine construction unit configured to perform: determining a distributed task system for task processing and determining a distributed task processing framework corresponding to the distributed task system; adding an initial task state machine to the distributed task processing framework to generate a task state machine.
[0145] In one exemplary embodiment of this disclosure, the state machine construction unit includes a state machine construction subunit, which is configured to perform: determining the state machine identifier of the initial task state machine and adding the state machine identifier to the task processing class; obtaining the lifecycle events of the initial task state machine and determining the event content of the lifecycle events; adding event annotation information to the lifecycle events according to the event content to generate task processing events; generating a task state machine based on the task processing class and the task processing events; and having a corresponding task processor for each task processing event.
[0146] In one exemplary embodiment of this disclosure, the state machine construction module further includes an event generation unit configured to perform: determining lifecycle processing logic for task processing; determining basic processing events and extended processing events based on the lifecycle processing logic; and generating lifecycle events based on the basic processing events and extended processing events.
[0147] In one exemplary embodiment of this disclosure, the state machine construction module further includes an event sorting unit, which is configured to perform: event filtering processing on multiple task processing events according to event annotation information to obtain at least one event to be executed; sorting the events to be executed to obtain an event sorting result, so as to execute the event to be executed according to the event sorting result.
[0148] In one exemplary embodiment of this disclosure, the task processing module 640 includes a task processing unit configured to perform: acquiring a lifecycle event corresponding to a task to be processed; determining a corresponding target transfer event from the lifecycle event according to target transfer logic; and invoking a corresponding target task processor according to the target transfer event to determine a task processing result based on the execution result of the target task processor.
[0149] In one exemplary embodiment of this disclosure, the task processing unit includes a first processing subunit, which is configured to perform: invoking a task transfer processor according to a trigger transfer event; performing state transfer processing on the task to be processed through the task transfer processor to obtain a state transfer result, and using the state transfer result as the task processing result.
[0150] In one exemplary embodiment of this disclosure, the task processing unit further includes a second processing subunit, which is configured to perform the following: invoking an exception transfer processor based on an exception transfer event; obtaining the exception transfer result obtained by the exception transfer processor for the task to be processed; and using the exception transfer result as the task processing result.
[0151] In one exemplary embodiment of this disclosure, the task processing unit further includes a third processing subunit, which is configured to perform the following: determining a state transition failure result based on a non-transition event, and using the state transition failure result as a task processing result.
[0152] Regarding the apparatus in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0153] Reference below Figure 7 To describe an electronic device 700 according to such an embodiment of the present disclosure. Figure 7 The electronic device 700 shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments disclosed herein.
[0154] like Figure 7 As shown, the electronic device 700 is presented in the form of a general-purpose computing device. The components of the electronic device 700 may include, but are not limited to: at least one processing unit 710, at least one storage unit 720, a bus 730 connecting different system components (including storage unit 720 and processing unit 710), and a display unit 740.
[0155] The storage unit stores program code that can be executed by the processing unit 710, causing the processing unit 710 to perform the steps described in the "Exemplary Methods" section above, according to various exemplary embodiments of this disclosure.
[0156] Storage unit 720 may include a readable medium in the form of a volatile storage unit, such as random access memory (RAM) 721 and / or cache memory 722, and may further include a read-only memory (ROM) 723.
[0157] Storage unit 720 may include a program / utility 724 having a set (at least one) program module 725, such program module 725 including but not limited to: operating system, one or more application programs, other program modules and program data, each or some combination of these examples may include an implementation of a network environment.
[0158] Bus 730 can represent one or more of several types of bus structures, including memory cell bus or memory cell controller, peripheral bus, graphics acceleration port, processing unit, or local bus using any of the multiple bus structures.
[0159] Electronic device 700 can also communicate with one or more external devices 770 (e.g., keyboard, pointing device, Bluetooth device, etc.), and with one or more devices that enable a user to interact with electronic device 700, and / or with any device that enables electronic device 700 to communicate with one or more other computing devices (e.g., router, modem, etc.). This communication can be performed via input / output (I / O) interface 750. Furthermore, electronic device 700 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 760. As shown, network adapter 760 communicates with other modules of electronic device 700 via bus 730. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with electronic device 700, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0160] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory including instructions, which can be executed by a processor of the device to perform the above-described task processing method. Optionally, the computer-readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.
[0161] In an exemplary embodiment, a computer program product is also provided, including a computer program / instructions, characterized in that the computer program / instructions, when executed by a processor, implement the task processing method described in any one of the preceding embodiments.
[0162] Other embodiments of the present disclosure will readily occur to those skilled in the art after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, with the true scope and spirit of the present disclosure being indicated by the following claims.
[0163] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.
Claims
1. A task processing method, characterized in that: include: In response to a task triggering event of a task to be processed, obtaining task execution information of the task to be processed; Determining the current task status of the task to be processed according to the task execution information; Acquire a corresponding target state machine according to the task type of the task to be processed, and determine a corresponding target transfer logic from the target state machine according to the current task state and the task triggering event, wherein the target state machine is a stateless state machine and is acquired from a pre-built task state machine; Triggering execution of the task to be processed according to the target transfer logic to obtain a task processing result; The task state machine is constructed by the following steps: determining a state machine identifier of an initial task state machine, and adding the state machine identifier to a task processing class; Obtaining a life cycle event of the initial task state machine, and determining event content of the life cycle event; Adding event annotation information to the lifecycle event according to the event content to generate a task processing event; Generate the task state machine based on the task processing class and the task processing event; The task processing event has a corresponding task processor.
2. The method according to claim 1, characterized in that The method further comprises: Obtaining a task type set; the task type set includes a plurality of candidate task types; Selecting a candidate task type from the task type set, and determining a plurality of task states corresponding to the candidate task type; Determine the transfer triggering events and state transfer logic between the plurality of task states, and generate an initial task state machine according to the plurality of task states, the transfer triggering events and the state transfer logic; A task state machine is generated based on the initial task state machine.
3. The method according to claim 2, characterized in that The generating a task state machine based on the initial task state machine comprises: Determine a distributed task system for performing task processing, and determine a distributed task processing framework corresponding to the distributed task system, wherein the distributed task processing framework includes the task processing class; The initial task state machine is added to the distributed task processing framework to generate the task state machine.
4. The method according to claim 1, characterized in that: Before obtaining the life cycle event of the initial task state machine, the method further includes: Determine the lifecycle processing logic of task processing, and determine the basic processing events and extended processing events according to the lifecycle processing logic; The life cycle event is generated according to the basic processing event and the extended processing event.
5. The method according to claim 1, characterized in that After generating the task processing event, the method further includes: Performing event screening processing on multiple task processing events according to the event annotation information to obtain at least one event to be executed; The events to be executed are sorted to obtain an event sorting result, and the events to be executed are executed according to the event sorting result.
6. The method according to claim 1, characterized in that The triggering of executing the to-be-processed task according to the target transfer logic to obtain a task processing result includes: Obtaining the life cycle event corresponding to the task to be processed; Determining a corresponding target transfer event from the life cycle events according to the target transfer logic; The corresponding target task processor is called according to the target transfer event to determine the task processing result based on the execution result of the target task processor.
7. The method according to claim 6, characterized in that The target transfer event includes a trigger transfer event, and calling a corresponding target task processor according to the target transfer event to determine the task processing result based on the execution result of the target task processor includes: Invoke a task transfer processor according to the trigger transfer event; The task transfer processor performs state transfer processing on the task to be processed to obtain a state transfer result, and uses the state transfer result as the task processing result.
8. The method according to claim 6, characterized in that The target transfer event includes an abnormal transfer event, and calling a corresponding target task processor according to the target transfer event to determine the task processing result based on the execution result of the target task processor includes: Calling an exception transfer processor according to the exception transfer event; An exception transfer result obtained by the exception transfer processor for the task to be processed is obtained, and the exception transfer result is used as the task processing result.
9. The method according to claim 6, characterized in that The target transfer event includes a non-transfer event, and the method further includes: A state transfer failure result is determined according to the non-transfer event, and the state transfer failure result is used as the task processing result.
10. A task processing device, characterized in that: include: An execution information acquisition module is configured to execute a task triggering event in response to a task to be processed and acquire task execution information of the task to be processed; A task status determination module is configured to determine the current task status of the to-be-processed task according to the task execution information; a target logic determination module, configured to execute acquiring a corresponding target state machine according to a task type of the task to be processed, and determining a corresponding target transfer logic from the target state machine according to the current task state and the task triggering event, wherein the target state machine is a stateless state machine, and the target state machine is acquired from a pre-built task state machine; A task processing module is configured to trigger the execution of the task to be processed according to the target transfer logic to obtain a task processing result; A state machine construction module is configured to determine a state machine identifier of an initial task state machine and add the state machine identifier to a task processing class; Obtaining a life cycle event of the initial task state machine, and determining event content of the life cycle event; Adding event annotation information to the lifecycle event according to the event content to generate a task processing event; Determine the task processing class and the task processing event to generate the task state machine; The task processing event has a corresponding task processor.
11. The device according to claim 10, characterized in that The task processing device further includes a state machine building module, wherein the state machine building module is configured to execute: Obtaining a task type set; the task type set includes a plurality of candidate task types; Selecting a candidate task type from the task type set, and determining a plurality of task states corresponding to the candidate task type; Determine the transfer triggering events and state transfer logic between the plurality of task states, and generate an initial task state machine according to the plurality of task states, the transfer triggering events and the state transfer logic; A task state machine is generated based on the initial task state machine.
12. The device according to claim 11, characterized in that The state machine construction module includes a state machine construction unit, and the state machine construction unit is configured to execute: Determine a distributed task system for performing task processing, and determine a distributed task processing framework corresponding to the distributed task system, wherein the distributed task processing framework includes the task processing class; The initial task state machine is added to the distributed task processing framework to generate the task state machine.
13. The device according to claim 10, characterized in that The state machine building module further includes an event generating unit, wherein the event generating unit is configured to execute: Determine the lifecycle processing logic of task processing, and determine the basic processing events and extended processing events according to the lifecycle processing logic; The life cycle event is generated according to the basic processing event and the extended processing event.
14. The device according to claim 10, characterized in that The state machine building module further includes an event sequencing unit, wherein the event sequencing unit is configured to perform: Performing event screening processing on multiple task processing events according to the event annotation information to obtain at least one event to be executed; The events to be executed are sorted to obtain an event sorting result, and the events to be executed are executed according to the event sorting result.
15. The device according to claim 10, characterized in that The task processing module includes a task processing unit, and the task processing unit is configured to execute: Obtaining the life cycle event corresponding to the task to be processed; Determining a corresponding target transfer event from the life cycle events according to the target transfer logic; The corresponding target task processor is called according to the target transfer event to determine the task processing result based on the execution result of the target task processor.
16. The device according to claim 15, characterized in that The target transfer event includes a trigger transfer event, and the task processing unit includes a first processing subunit, and the first processing subunit is configured to execute: Invoke a task transfer processor according to the trigger transfer event; The task transfer processor performs state transfer processing on the task to be processed to obtain a state transfer result, and uses the state transfer result as the task processing result.
17. The device according to claim 15, characterized in that The target transfer event includes an abnormal transfer event, and the task processing unit further includes a second processing subunit, and the second processing subunit is configured to perform the following steps: Calling an exception transfer processor according to the exception transfer event; An exception transfer result obtained by the exception transfer processor for the task to be processed is obtained, and the exception transfer result is used as the task processing result.
18. The device according to claim 15, characterized in that The target transfer event includes a non-transfer event, and the task processing unit further includes a third processing sub-unit, and the third processing sub-unit is configured to perform the following steps: A state transfer failure result is determined according to the non-transfer event, and the state transfer failure result is used as the task processing result.
19. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the task processing method according to any one of claims 1 to 9.
20. A computer-readable storage medium, characterized in that: When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the task processing method as claimed in any one of claims 1 to 9.
21. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the task processing method according to any one of claims 1 to 9 is implemented.
Citation Information
Patent Citations
Condition-based task scheduling method and device, equipment and storage medium
CN110333940A
State machine configuration method and device, equipment and readable storage medium
CN110825428A
Information acquisition method and device, storage medium and terminal
CN111338609A
Service state circulation maintenance method and device and electronic equipment
CN112907198A