Disclosure of Invention
Based on the problems existing in the prior art, the embodiment of the invention provides a workflow engine, a scheduling method, a scheduling device, equipment and a storage medium, which can realize global task view, unified arrangement and management of task flows of different components, no separate definition of service flows among the components is needed, pain points of associated inquiry of flow data and service data can be solved, and a service system can associate the flow data to realize complex associated inquiry.
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 one business component, and each workflow SDK comprises a universal application program interface API required by workflow circulation operation; each business component comprises a simple copy of flow data; the workflow SDK is used for synchronizing task information from the central workflow engine to simple copies of flow data included in business components corresponding to the workflow SDK; the business component is used for executing tasks according to the information of the synchronous tasks in the simple flow copies included in the business component; the workflow SDK is further configured to synchronize a state of a current task executed by a service component corresponding to the workflow SDK to the central workflow engine.
Optionally, the simple copy of the flow data included in each business component includes information of effective tasks of the business component, and no complete definition information and circulation conditions of the workflow are included.
Optionally, the service component includes a service component application server and a service component database; the workflow SDK corresponding to the service component is embedded into the service component application server; and the simple copy of the flow data included in the service component is a new service database table in the service component database.
Optionally, the service database table is a wf_task table, and the wf_task table only contains information of effective TASKs of the service component where the wf_task table is located, and no complete definition information and circulation conditions of the workflow exist.
Optionally, each of the workflow SDKs is a jar packet.
Optionally, the state of the current task includes: completion, failure, and suspension.
Optionally, the business components and the workflow SDKs are in one-to-one correspondence, and business components corresponding to different workflow SDKs are different.
The embodiment of the invention realizes the unified management and viewing of the service workflow processes of the distributed system, and different processes of each service system can be completely transmitted to the central workflow engine for scheduling. Based on the centralized workflow, the pain points of the flow data and the business data set are perfectly solved by using a small amount of copy data, and the workflow engine is basically decoupled from the business data without concerning the complex state change of the business data.
In addition, based on the workflow engine provided by the embodiment of the invention, unified management of different versions of flows of the multi-service assembly can be realized, and flow data of different versions of different service assemblies can coexist and uniformly delivered to the central flow engine to manage task flows.
In a second aspect, an embodiment of the present invention provides a scheduling method, where the method is applied to a workflow engine, and the workflow engine includes: a central workflow engine, at least one workflow software development kit SDK; each workflow SDK is correspondingly embedded into one business component, and each workflow SDK comprises a universal application program interface API required by workflow circulation operation; each business component comprises a simple copy of flow data; the method comprises the following steps:
The central workflow engine synchronizes the task information to a simple copy of the flow data included in a first business 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 performed by the first business component from the first workflow SDK.
Optionally, the simple copy of the flow data included in each business component includes information of effective tasks of the business component, and no complete definition information and circulation condition of workflow are included; the business component comprises a business component application server and a business component database; the workflow SDK corresponding to the service component is embedded into the service component application server; and the simple copy of the flow data included in the service component is a new service database table in the service component database.
Optionally, the service database table is a wf_task table, and the wf_task table only contains information of effective TASKs of the service component where the wf_task table is located, and no complete definition information and circulation conditions of the workflow exist.
Optionally, each of the workflow SDKs is a jar packet.
Optionally, the business components and the workflow SDKs are in one-to-one correspondence, and business components corresponding to different workflow SDKs are different.
In a third aspect, an embodiment of the present invention provides a scheduling apparatus, where the apparatus is applied to a central workflow engine included in a workflow engine, and the workflow engine further includes at least one workflow software development kit SDK; each workflow SDK is correspondingly embedded into one business component, and each workflow SDK comprises a universal application program interface API required by workflow circulation operation; each business component comprises a simple copy of flow data; the device comprises: the task synchronization module and the task state updating module; the task synchronization module is used for synchronizing the information of the task to a simple copy of the flow data included in the first business component corresponding to the first workflow SDK through the first workflow SDK; the first workflow SDK is one of the at least one workflow SDK; the task state update module is configured to receive a state of a current task executed by a first service component from the first workflow SDK.
Optionally, the scheduling device is further configured to implement other functions implemented by the central workflow engine in the workflow engine according to the first aspect, which are not described in detail herein.
In a fourth aspect, an embodiment of the present invention provides an electronic device, including: a processor, a storage medium storing machine-readable instructions executable by the processor, the processor and the storage medium communicating over a bus when the electronic device is operating, the processor executing the machine-readable instructions to perform the steps of the method as described in the second aspect.
In a fifth aspect, embodiments of the present invention provide a storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the method according to the second aspect.
The advantages of the second to fifth aspects may be referred to in the first aspect, and are not described here.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described with reference to the accompanying drawings in the embodiments of the present invention, and it should be understood that the drawings in the present invention are for the purpose of illustration and description only and are not intended to limit the scope of the present invention. In addition, it should be understood that the schematic drawings are not drawn to scale. A flowchart, as used in this disclosure, illustrates operations implemented according to some embodiments of the present invention. It should be understood that the operations of the flow diagrams may be implemented out of order and that steps without logical context may be performed in reverse order or concurrently. Moreover, one or more other operations may be added to or removed from the flow diagrams by those skilled in the art under the direction of the present disclosure.
In addition, the described embodiments of the invention are only some, but not all, embodiments of the invention. The components of the 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 invention, as 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 made by a person skilled in the art without making any inventive effort, are intended to be within the scope of the present invention.
It should be noted that the term "comprising" will be used in embodiments of the invention to indicate the presence of the features stated hereafter, but not to exclude the addition of other features. It should also be noted that: like reference numerals and letters denote like items in the following figures, and thus once an item is defined in one figure, no further definition or explanation thereof is necessary in the following figures. In the description of the present invention, it should also be noted that the terms "first," "second," "third," and the like are used merely to distinguish between descriptions and should not be construed as indicating or implying relative importance.
The concept of workflow originates in the field of production organization and office automation and is one proposed for having fixed program activity in daily work. Generally, the tasks are executed and monitored according to certain rules and procedures by decomposing the work into defined tasks or roles, so as to achieve the purposes of improving the work efficiency, better controlling the procedure, enhancing the service to the clients, effectively managing the business processes and the like.
The main problems that workflow mainly solves are: to achieve a certain business objective, a computer is used to automatically transfer documents, information, or tasks between multiple participants according to certain predetermined rules. In the implementation of the workflow, the workflow engine is a part of an application system, can provide a reusable and flexibly configurable flow solution for each service system, and can decide the flow and the jump according to different roles, division of work and conditions. For example, the workflow engine may include important functions of node management, flow sample management, etc. of the flow.
Existing workflow systems engines typically include an embedded workflow engine and a centralized workflow engine.
The embedded workflow engine is deployed by packing a workflow engine main body program and an application system program together, and a database table and service data required by the workflow engine share one database and are used for single application. In a distributed system, the embedded workflow engine cannot present a unified global workflow view. The processes among the components cannot be directly connected, and all the service systems are mutually communicated in pairs to form a complex network communication structure, so that reliability and maintainability are at risk.
The centralized workflow engine is characterized in that a workflow engine program and a database are independently deployed and serve as independent components to provide services, the workflow engine is uniformly docked by each business component, and the workflow engine is interactively invoked through a network. The scheme can integrate the task flow data of each business component and uniformly connect the working flows of each component in series. Because the centralized workflow engine is deployed independently of the database, isolated from the business component database, the workflow data is difficult to combine with the business data. The centralized workflow engine cannot directly combine service data to perform associated query, and cannot perform various complex sequencing screening on task sets of required nodes according to service requirements. The business system is usually required to push a certain amount of data to the workflow engine, and the workflow engine can perform the association query by using the copy of the data and the information of the flow task, but this faces the problem of timeliness of the synchronization of the business data. Because the business data changes in real time, a plurality of burial points are needed in the business process, and the data is synchronized to the workflow engine, the high coupling between the workflow engine and the business components can be caused, and the workload of demand analysis and development can be greatly increased.
Under the background technology, the embodiment of the invention provides a workflow engine, which is a centralized workflow engine based on flow data synchronization, can realize global task view, and the task flows of different components are uniformly arranged and managed, so that the service flows among the components do not need to be defined separately. The run-time cross-component flow jumps do not require custom proprietary interfaces. The program writing mode is indistinguishable from the flow in the component. The complexity of task flow between components is shielded, so that the cross-component tasks are completely transparent to the business system.
In addition, the workflow engine provided by the embodiment of the invention can also solve the pain point of the related query of the flow data and the service data, and the service system can be related to the flow data to realize the complex related query. The flow engine does not in principle hold business data, and is decoupled from the business system.
Fig. 1 shows a schematic structural diagram of a workflow engine according to an embodiment of the present invention.
As shown in fig. 1, the workflow engine includes: a central workflow engine and n workflow software development kits (softwaredevelopmentkit, SDK), n being an integer greater than or equal to 1. Each of the n workflow SDKs is correspondingly embedded into one service component, each workflow SDK includes a universal application program interface (applicationprogramminginterface, API) required for workflow circulation operation, and service components corresponding to different workflow SDKs are different.
That is, if n service components exist, n workflow SDKs exist, and the service components and the workflow SDKs are in a one-to-one correspondence. 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 flow data. When the workflow engine provided by the embodiment of the invention is used, different flows of each business system can be completely scheduled by the central workflow engine, and the central workflow engine can schedule corresponding business components to execute tasks through the workflow SDK.
Taking the example of the central workflow engine scheduling the first business 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 business component through the first workflow SDK. In other words, the first workflow SDK may synchronize data of the first task from the central workflow engine into the flow data simple copy of the first business component. The first business component can then execute the first task based on the information of the first task synchronized in the simple copy of the flow.
It should be appreciated that in this example, the first business component may be any business component, related to the business system corresponding to the first task; the first workflow SDK is a workflow SDK embedded in the first business component.
In the embodiment of the present invention, the first workflow SDK may further 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 completes the first task, the first workflow SDK corresponding to the first service component may be invoked to notify the central workflow engine that the first task is complete.
Optionally, for each business component, the simple copy of the flow data included in the business component includes information of effective tasks of the business component, and no complete definition information and circulation conditions of the workflow are included.
Fig. 2 shows another structural schematic diagram of a workflow engine according to an embodiment of the present invention.
As shown in fig. 2, in an 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 business component may be embedded in the business component application server. The central workflow engine may be comprised of a flow engine and a flow engine database.
The business component includes a simple copy of the flow data may be implemented by newly building a business database table in the business component database as the simple copy of the flow data. For example, the service database table may be a wf_task table. That is, the wf_task table only contains information of valid TASKs of the current service component (the service component where the wf_task table is located), and no complete definition information and circulation conditions of the workflow exist.
The wf_task table is exemplarily shown below.
WF_TASK table
Column name |
Meaning of |
ID |
Physical primary key |
REV |
Optimistic lock |
RASK_ID |
Task ID |
TASK_KEY |
Task type ID |
BUSINESS_KEY |
Service association number |
ASSIGNEE |
Executive man |
STATUS |
Task status |
PROC_INST_ID |
Flow instance ID |
PROC_DEF_ID |
Flow definition ID |
CREATE_TIME |
Creation time |
MODIFY_TIME |
Modification time |
MODIFY_BY |
Modifier(s) |
When a new TASK is generated by the flow engine, the 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 a WF_TASK table in the service component database, and the state of the current TASK is changed to be synchronous with the flow engine.
In the embodiment of the invention, when the data is queried, each service component working pool does not need to interact with a central workflow engine, can directly use the data in the WF_TASK table to perform associated query with the service data, and can perform complex ordering and paging without limitation.
Optionally, when generating a new task and sending new task information to the service component application server, the flow engine may send the new task information through a message middleware to notify the workflow SDK to synchronize the new task information. Similarly, the workflow SDK can synchronize flow data (e.g., task status) of business components to a central workflow engine through message middleware. By means of the message mechanism, the flow data of the business components and the central workflow engine can be synchronized in quasi-real time.
Alternatively, if message middleware is not able to guarantee 100% reliability, it is also possible to have a high frequency timing batch for retries.
Optionally, if the process is in a cross-component process jump scene, only new task information is synchronized, so that the data copy of the corresponding task is ensured to be created, and the workflow SDK is not in charge of task state update. The task state synchronization is responsible for updating when the workflow SDK initiates the task state and the flow circulation.
Fig. 3 is a schematic diagram illustrating 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 trigger the workflow SDK to synchronize TASK information (data) to the wf_task table according to the method described in the foregoing embodiments, and then, the service component performs TASKs. After the task is finished, the workflow engine can firstly judge whether the end point of the flow is reached, and if so, the flow is finished. If not, continuing to execute the circulation operation.
It can be seen that in the embodiment of the present invention, since the workflow SDK is embedded with a service component (or a service system) as a part of a program, the workflow SDK can read and write a service database while interfacing with a central workflow engine, and thus a complete workflow engine is not required to be embedded.
Optionally, in the embodiment of the present invention, the workflow SDK corresponding to the service component may be a jar packet. That is, embodiments of the present invention may implant a lightweight workflow SDK into business components.
In summary, the embodiment of the invention realizes unified management and viewing of the service workflow processes of the distributed system, and different processes of each service system can be completely dispatched by the central workflow engine. Based on the centralized workflow, the pain points of the flow data and the business data set are perfectly solved by using a small amount of copy data, and the workflow engine is basically decoupled from the business data without concerning the complex state change of the business data.
In addition, based on the workflow engine provided by the embodiment of the invention, unified management of different versions of flows of the multi-service assembly can be realized, and flow data of different versions of different service assemblies can coexist and uniformly delivered to the central flow engine to manage task flows.
Based on the workflow engine described in the foregoing embodiment, the embodiment of the present invention further provides a scheduling method. Fig. 4 shows a flow chart of a scheduling method according to an embodiment of the present invention, as shown in fig. 4, where the method includes:
S401, synchronizing task information to a simple copy of flow data included in a first business component corresponding to a first workflow SDK through the first workflow SDK by a central workflow engine.
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 business component from the first workflow SDK.
Optionally, the simple copy of the flow data included by each service component includes information of effective tasks of the service component, and no complete definition information and circulation conditions of the workflow are provided; the business component comprises a business component application server and a business component database; the workflow SDK corresponding to the business component is embedded into the business component application server; the simple copy of the flow data included in the service component is a new service database table in the service component database.
Optionally, each workflow SDK is a jar packet.
Based on the scheduling method described in the foregoing embodiment, the embodiment of the present invention further provides a scheduling device, which may be used to implement the scheduling method described in the foregoing embodiment. Fig. 5 shows a schematic structural diagram of a scheduling apparatus according to an embodiment of the present invention.
As shown in fig. 5, the scheduling apparatus may at least include: a task synchronization module 501 and a task status update module 502. The task synchronization module 501 may be configured to synchronize, by using the first workflow SDK, information of a task to a simple copy of flow data included in a first service component corresponding to the first workflow SDK. The first workflow SDK is one of the at least one workflow SDK. The task state update module 502 can be configured to receive a state of a current task performed by a first business component from the first workflow SDK.
The above-described apparatus may be integrated into a server, a computer, or the like, and the present invention is not limited thereto. It can be clearly understood by those skilled in the art that, for convenience and brevity of description, a specific working process of the scheduling apparatus may refer to a corresponding process of the scheduling method described in the foregoing method embodiment, which is not repeated in the present invention.
It should be understood that the above-described device embodiments are merely illustrative, and that the devices and methods disclosed in the embodiments of the present invention may be implemented in other manners. For example, the modules may be divided into only one logic function, and there may be another division manner when actually implemented, and for example, a plurality of modules or components may be combined or may be integrated into another system, or some features may be omitted or not performed. In addition, the coupling or direct coupling or communication connection shown or discussed with respect to each other may be through some communication interface, indirect coupling or communication connection of devices or modules, electrical, mechanical, or other form. In addition, each functional unit in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in 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 this understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art or in the form of a software product stored in a storage medium, comprising several instructions for causing a processor to carry out all or part of the steps of the method according to the embodiments of the present invention.
That is, those skilled in the art will appreciate that embodiments of the invention may be implemented in any of the forms 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, which may be a storage medium such as a usb disk, a mobile hard disk, a ROM, a RAM, a magnetic disk or an optical disk, where a computer program may be stored, and when the computer program is executed by a processor, the steps of the scheduling method described in the foregoing method embodiment are executed. The specific implementation manner and the technical effect are similar, and are not repeated here.
Optionally, the embodiment of the present invention further provides an electronic device, where the electronic device may be a server, a computer, or other devices, and fig. 6 shows a schematic structural diagram of the electronic device provided by the embodiment of the present invention.
As shown in fig. 6, the electronic device may include: processor 601, storage medium 602, and bus 603, storage medium 602 storing machine-readable instructions executable by processor 601, when the electronic device is running, the processor 601 communicates with storage medium 602 via bus 603, and processor 601 executes the machine-readable instructions to perform the steps of the scheduling method as described in the previous embodiments. The specific implementation manner and the technical effect are similar, and are not repeated here.
For ease of illustration, only one processor is depicted in the above-described electronic device. It should be noted, however, that in some embodiments, the electronic device of the present invention may also include multiple processors, and thus, steps performed by one processor described in the present invention may also be performed jointly by multiple processors or separately.
The foregoing is merely illustrative of the present invention, and the present invention is not limited thereto, and any person skilled in the art will readily appreciate variations or alternatives within the scope of the present invention. Therefore, the protection scope of the invention is subject to the protection scope of the claims.