Disclosure of Invention
Based on the problems in the prior art, embodiments of the present invention provide a workflow engine, a workflow scheduling method, a workflow scheduling apparatus, a workflow scheduling device, and a workflow storage medium, which can implement a global task view, unified arrangement and management of task flows of different components, do not need to define service flows among components separately, and can solve pain points of association query between process data and service data, and a service system can associate process data to implement complex association query.
In a first aspect, an embodiment of the present invention provides a workflow engine, including: a central workflow engine, at least one workflow software development kit SDK; each workflow SDK is correspondingly embedded into a service component and comprises a general application program interface API required by workflow circulation operation; each business component comprises a simple copy of the process data; the workflow SDK is used for synchronizing the information of the task from the central workflow engine to the simple copy of the process data included in the service component corresponding to the workflow SDK; the business component is used for executing tasks according to the information of the tasks synchronized in the simple process copy; the workflow SDK is also used for synchronizing the state of the current task executed by the service component corresponding to the workflow SDK to the central workflow engine.
Optionally, the simple process data copy included in each business component includes information of an effective task of the business component, and complete definition information and flow conditions of no workflow.
Optionally, the service component includes a service component application server and a service component database; embedding the workflow SDK corresponding to the service component into the service component application server; and the simple copy of the process data included by the business component is a business database table newly built in the business component database.
Optionally, the service database table is a WF _ TASK table, and the WF _ TASK table only contains information of valid TASKs of the service component where the service component is located, and has no complete definition information and flow conditions of the workflow.
Optionally, each of the workflow SDKs is a jar packet.
Optionally, the state of the current task includes: completion, failure, and suspension.
Optionally, the service components and the workflow SDKs are in a one-to-one correspondence, and the service components corresponding to different workflow SDKs are different.
The embodiment of the invention realizes the unified management and check of the service workflow processes of the distributed system, and different processes of each service system can be all dispatched by the central workflow engine. On the basis of a centralized workflow, pain points of process data and business data sets are perfectly solved by using a small amount of duplicate data, a workflow engine is basically decoupled from the business data, and complex state changes of the business data do not need to be concerned.
In addition, based on the workflow engine provided by the embodiment of the invention, the unified management of the flows of different versions of the multi-service component can be realized, and the flow data of different versions of different service components can coexist and be uniformly handed over to the central flow engine to manage the task flow.
In a second aspect, an embodiment of the present invention provides a scheduling method, where the method is applied to a workflow engine, where the workflow engine includes: a central workflow engine, at least one workflow software development kit SDK; each workflow SDK is correspondingly embedded into a service component and comprises a general application program interface API required by workflow circulation operation; each business component comprises a simple copy of the process data; the method comprises the following steps:
the central workflow engine synchronizes the information of the task to a simple copy of process data included in a first service component corresponding to a first workflow SDK through the first workflow SDK; the first workflow SDK is one of the at least one workflow SDK; the central workflow engine receives a status of a current task executed by the first business component from the first workflow SDK.
Optionally, the simple process data copy included in each business component includes information of an effective task of the business component, and complete definition information and circulation conditions of no workflow; the service component comprises a service component application server and a service component database; embedding the workflow SDK corresponding to the service component into the service component application server; and the simple copy of the process data included by the business component is a business database table newly built in the business component database.
Optionally, the service database table is a WF _ TASK table, and the WF _ TASK table only contains information of valid TASKs of the service component where the service component is located, and has no complete definition information and flow conditions of the workflow.
Optionally, each of the workflow SDKs is a jar packet.
Optionally, the service components and the workflow SDKs are in a one-to-one correspondence, and the service components corresponding to different workflow SDKs are different.
In a third aspect, an embodiment of the present invention provides a scheduling apparatus, where the scheduling apparatus is applied to a central workflow engine included in a workflow engine, where the workflow engine further includes at least one workflow software development kit SDK; each workflow SDK is correspondingly embedded into a service component and comprises a general application program interface API required by workflow circulation operation; each business component comprises a simple copy of the process data; the device comprises: the system comprises a task synchronization module and a task state updating module; the task synchronization module is used for synchronizing the information of the task to a simple process data copy included in a first service component corresponding to a first workflow SDK through the first workflow SDK; the first workflow SDK is one of the at least one workflow SDK; the task state updating module is used for receiving the state of the current task executed by the first service component from the first workflow SDK.
Optionally, the scheduling device is further configured to implement other functions implemented by a central workflow engine in the workflow engines described in the first aspect, which are not described herein any more.
In a fourth aspect, an embodiment of the present invention provides an electronic device, including: a processor, a storage medium and a bus, the storage medium storing machine-readable instructions executable by the processor, the processor and the storage medium communicating via the bus when the electronic device is operating, the processor executing the machine-readable instructions to perform the steps of the method according to the second aspect.
In a fifth aspect, the present invention provides a storage medium, on which a computer program is stored, which, when executed by a processor, performs the steps of the method according to the second aspect.
The beneficial effects described in the second to fifth aspects above can be referred to the first aspect, and are not described herein again.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it should be understood that the drawings in the present invention are for illustrative and descriptive purposes only and are not used to limit the scope of the present invention. Additionally, it should be understood that the schematic drawings are not necessarily drawn to scale. The flowcharts used in this disclosure illustrate operations implemented according to some embodiments of the present invention. It should be understood that the operations of the flow diagrams may be performed out of order, and steps without logical context may be performed in reverse order or simultaneously. One skilled in the art, under the direction of this summary, may add one or more other operations to, or remove one or more operations from, the flowchart.
In addition, the described embodiments of the present invention are only some embodiments of the present invention, and not all embodiments of the present invention. The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present invention, presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present invention without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the term "comprising" will be used in the embodiments of the invention to indicate the presence of the features stated hereinafter, but does not exclude the addition of further features. It should also be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures. In the description of the present invention, it should also be noted that the terms "first", "second", "third", and the like are used for distinguishing the description, and are not intended to indicate or imply relative importance.
The concept of workflow originates from the field of production organization and office automation, and is a concept proposed for having fixed program activities in daily work. Generally, work is divided into defined tasks or roles, the tasks are executed according to certain rules and processes, and the tasks are monitored, so that the purposes of improving the work efficiency, better controlling the processes, enhancing the service to customers, effectively managing business processes and the like are achieved.
The main problems mainly solved by the workflow are as follows: to achieve a business goal, documents, information, or tasks are automatically communicated between multiple participants using a computer according to some predetermined rule. In the implementation of the workflow, the workflow engine is used as a part of an application system, can provide a reusable and flexibly configurable flow solution for each business system, and can determine flow and jump according to different roles, division of labor and conditions. For example, the workflow engine may include important functions for node management, flow direction management, process sample management, etc. of the process.
Existing workflow-based engines typically include embedded workflow engines and centralized workflow engines.
The embedded workflow engine is a workflow engine main body program and an application system program which are packaged together for deployment, and a database table and business data required by the workflow engine share one database and are mostly used for single application. In a distributed system, an embedded workflow engine cannot present a unified global workflow view. The flows between the components cannot be directly connected, and all the service systems are mutually communicated in pairs to form a complex mesh communication structure, so that the reliability and maintainability all have risks.
The centralized workflow engine refers to a workflow engine program and a database which are independently deployed and serve as independent components to provide services for the outside, and each business component is uniformly connected with the workflow engine in an abutting mode and calls the workflow engine through network interaction. The scheme can integrate the task flow data of each service component and uniformly connect the work flows of each component in series. Because the centralized workflow engine is deployed independently of the database, and is isolated from the business component database, workflow data is difficult to integrate with business data. The centralized workflow engine cannot directly combine the service data to perform association query, and cannot perform various complex sequencing and screening on the task set of the required nodes according to the service requirements. A certain amount of data is generally pushed to a workflow engine by a business system, and the workflow engine uses a copy of the data to perform association query in combination with information of a process task, but this may face the problem of timeliness of business data synchronization. Due to real-time change of business data, data needs to be synchronized to a workflow engine at multiple buried points in a business process, high coupling between the workflow engine and a business component can be caused, and workload of demand analysis and development is greatly increased.
In this background, an embodiment of the present invention provides a workflow engine, which is a centralized workflow engine based on process data synchronization, and can implement a global task view, unified arrangement and management of task flows of different components, and a service process between the components does not need to be separately defined. The jump of the cross-component flow in the operation process does not need to customize a special interface. The program writing mode is not different from the flow circulation in the component. The complexity of task flow between the components is shielded, so that the cross-component task is completely transparent to the service system.
In addition, the workflow engine provided by the embodiment of the invention can also solve the pain point of the correlation query of the process data and the service data, and the service system can correlate the process data to realize the complex correlation query. The process engine does not store business data in principle, and is decoupled from the business system.
Fig. 1 shows a schematic structural diagram of a workflow engine provided by an embodiment of the present invention.
As shown in fig. 1, the workflow engine includes: a central workflow engine and n workflow Software Development Kit (SDK), n being an integer greater than or equal to 1. Each workflow SDK in the n workflow SDKs is embedded into one service component, each workflow SDK includes an Application Programming Interface (API) required by the workflow circulation operation, and service components corresponding to different workflow SDKs are different.
That is, if there are n service components, there are n workflow SDKs, and there is a one-to-one correspondence between the service components and the workflow SDKs. It will be appreciated that different business components belong to different business systems.
With continued reference to fig. 1, in an embodiment of the present invention, each business component may include a simple copy of the process data. When the workflow engine provided by the embodiment of the invention is used, different processes of each service system can be all dispatched by the central workflow engine, and the central workflow engine can dispatch corresponding service components to execute tasks through the workflow SDK.
Taking the example that the central workflow engine schedules the first service component to execute the first task, the central workflow engine may write the information of the first task into the simple copy of the flow data of the first service component through the first workflow SDK. In other words, the first workflow SDK can synchronize data of the first task from the central workflow engine into the simple copy of the flow data of the first business component. The first business component can then execute the first task based on the information of the synchronized first task in the simple copy of the flow.
It should be understood that in this example, the first business component may be any one of the business components, relating to the business system corresponding to the first task; the first workflow SDK is a workflow SDK embedded in the first service component.
In the embodiment of the present invention, the first workflow SDK may also synchronize the state of the current task (e.g., the first task) executed by the first service component to the central workflow engine. Optionally, the state of the current task includes: completion, failure, and suspension.
For example, after the first service component executes the first task, the first service component may call a first workflow SDK corresponding to the first service component to notify the central workflow engine that the first task is completed.
Optionally, for each business component, the simple copy of the process data included in the business component includes information of the effective task of the business component, and complete definition information and flow conditions of the workflow are absent.
Fig. 2 is another schematic structural diagram of the workflow engine provided by the embodiment of the present invention.
As shown in fig. 2, in the embodiment of the present invention, a service component may include a service component application server and a service component database. The workflow SDK corresponding to the service component can be embedded into the service component application server. The central workflow engine may be comprised of a process engine and a process engine database.
The simple process data copy included in the business component can be realized by establishing a new business database table in the business component database as the simple process data copy. For example, the service database table may be a WF _ TASK table. That is, the WF _ TASK table only contains the information of the valid TASKs of the current service component (the service component where the WF _ TASK table is located), and there is no complete definition information and flow conditions of the workflow.
Exemplarily, the WF _ TASK table is as follows.
WF _ TASK table
When a new TASK is generated by the process engine, new TASK information can be sent to the service component application server, and after the service component application server receives the new TASK information, the corresponding workflow SDK can write the information of the new TASK into the WF _ TASK table in the service component database and change the state of the current TASK to be synchronized with the process engine.
In the embodiment of the invention, when each service component working pool queries data, the interaction with a central workflow engine is not needed, the data in the WF _ TASK table can be directly used for performing associated query with the service data, and the complex sequencing and paging can be performed without limitation.
Optionally, when a new task is generated and new task information is sent to the service component application server, the flow engine may send the new task information through message middleware to notify the workflow SDK to synchronize the information of the new task. Similarly, the workflow SDK can synchronize the business component's flow data (e.g., task state) to the central workflow engine through message middleware. Through a message mechanism, the process data of the business components and the central workflow engine can realize quasi-real-time synchronization.
Alternatively, if the message middleware cannot guarantee 100% reliability, there may also be a high frequency of timing batches for retries.
Optionally, if the process is in a cross-component flow jump scenario, only new task information is synchronized, it is ensured that a data copy of a corresponding task is created, and the workflow SDK is not responsible for task state update. The synchronization of the task state is updated when the workflow SDK initiates the task state and the process flow.
Illustratively, fig. 3 shows a schematic diagram of a task execution flow provided by an embodiment of the present invention. As shown in fig. 3, in a complete circulation operation, the workflow engine may first trigger the workflow SDK to synchronize TASK information (data) to the WF _ TASK table according to the method described in the foregoing embodiment, and then the service component executes the TASK. After the task is finished, the workflow engine may first determine whether the process end point is reached, and if so, the process is finished. If not, the circulation operation is continuously executed.
In the embodiment of the present invention, since the workflow SDK is embedded in the service component (or in the service system) as a part of the program, the workflow SDK can read and write the service database while interfacing with the central workflow engine, and thus, it is not necessary to embed a complete workflow engine.
Optionally, in this embodiment of the present invention, the workflow SDK corresponding to the service component may be a jar packet. That is, the embodiment of the present invention may embed a lightweight workflow SDK to the service component.
In summary, the embodiment of the present invention realizes unified management and check of the service workflow processes of the distributed system, and different processes of each service system can be all dispatched by the central workflow engine. On the basis of a centralized workflow, pain points of process data and business data sets are perfectly solved by using a small amount of duplicate data, a workflow engine is basically decoupled from the business data, and complex state changes of the business data do not need to be concerned.
In addition, based on the workflow engine provided by the embodiment of the invention, the unified management of the flows of different versions of the multi-service component can be realized, and the flow data of different versions of different service components can coexist and be uniformly handed over to the central flow engine to manage the task flow.
Based on the workflow engine described in the foregoing embodiment, an embodiment of the present invention further provides a scheduling method. Fig. 4 is a flowchart illustrating a scheduling method according to an embodiment of the present invention, and as shown in fig. 4, the method includes:
s401, the central workflow engine synchronizes the information of the task to the simple process data copy included in the first service component corresponding to the first workflow SDK through the first workflow SDK.
Wherein the first workflow SDK is one of the at least one workflow SDK.
S402, the central workflow engine receives the state of the current task executed by the first service component from the first workflow SDK.
Optionally, the simple process data copy included in each business component includes information of effective tasks of the business component, and complete definition information and circulation conditions of no workflow are included; the service component comprises a service component application server and a service component database; embedding a workflow SDK corresponding to the service component into a service component application server; the simple copy of the process data included in the business component is a business database table newly built in the business component database.
Optionally, each workflow SDK is a jar packet.
Based on the scheduling method described in the foregoing embodiment, an embodiment of the present invention further provides a scheduling apparatus, which may be used to implement the scheduling method described in the foregoing embodiment. Fig. 5 is a schematic structural diagram illustrating a scheduling apparatus according to an embodiment of the present invention.
As shown in fig. 5, the scheduling apparatus may include at least: atask synchronization module 501 and a taskstatus update module 502. Thetask synchronization module 501 may be configured to synchronize information of a task to a simple copy of process data included in a first service component corresponding to a first workflow SDK through the first workflow SDK. The first workflow SDK is one of the at least one workflow SDK. The taskstatus update module 502 can be configured to receive a status of a current task executed by a first business component from the first workflow SDK.
The above-mentioned apparatus can be integrated into a server, a computer, and other devices, and the present invention is not limited herein. It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working process of the scheduling apparatus may refer to the corresponding process of the scheduling method described in the foregoing method embodiment, and is not described in detail herein.
It should be understood that the above-described apparatus embodiments are merely exemplary, and that the apparatus and method disclosed in the embodiments of the present invention may be implemented in other ways. For example, the division of the modules into only one logical functional division may be implemented in other ways, and for example, multiple modules or components may be combined or integrated into another system, or some features may be omitted, or not implemented. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or modules through some communication interfaces, and may be in an electrical, mechanical or other form. In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a non-volatile computer-readable storage medium executable by a processor. Based on such understanding, the technical solution of the present invention or parts thereof which substantially contribute to the prior art may be embodied in the form of a software product stored in a storage medium and including instructions for causing a processor to execute the steps of all or part of the method according to the embodiments of the present invention.
That is, those skilled in the art will appreciate that embodiments of the present invention may be implemented in any form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects.
Based on this, the embodiment of the present invention further provides a program product, where the program product may be a storage medium such as a usb disk, a removable hard disk, a ROM, a RAM, a magnetic disk or an optical disk, and the storage medium may store a computer program, and the computer program is executed by a processor to perform the steps of the scheduling method as described in the foregoing method embodiment. The specific implementation and technical effects are similar, and are not described herein again.
Optionally, an embodiment of the present invention further provides an electronic device, where the electronic device may be a server, a computer, or a like device, and fig. 6 illustrates a schematic structural diagram of the electronic device provided in the embodiment of the present invention.
As shown in fig. 6, the electronic device may include: aprocessor 601, astorage medium 602 and abus 603, wherein thestorage medium 502 stores machine-readable instructions executable by theprocessor 501, when the electronic device is operated, theprocessor 601 communicates with thestorage medium 602 through thebus 603, and theprocessor 601 executes the machine-readable instructions to execute the steps of the scheduling method as described in the foregoing embodiments. The specific implementation and technical effects are similar, and are not described herein again.
For ease of illustration, only one processor is described in the above electronic device. However, it should be noted that in some embodiments, the electronic device in the present invention may further include multiple processors, and thus, the steps performed by one processor described in the present invention may also be performed by multiple processors in combination or individually.
The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and the present invention shall be covered thereby. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.