About Flowable Songge has updated several articles, but considering that some friends may have never been in contact with the process engine, there are some basic content that I will sort out with my friends.
1. Why Workflows Are Needed
After Song Ge forwarded the previous article to the circle of friends, some friends commented that they have not understood why workflow is needed. Today we will talk about this topic first.
Suppose I have a request for leave, the process is as follows:
The leave can be submitted to my boss, and the boss can choose to approve or reject it. Regardless of whether it is approved or rejected, a notification will be given to me.
This process is relatively simple. We can easily think of a solution, which can be solved without workflow. There is a special leave form. When A wants to ask for leave, a record is added to the leave form. The content of this record includes the leave request. The number of days, reason, the approver B of the leave request, and a field named status, this status field indicates the current status of the leave request (to be approved, approved or rejected), and then B logs in to the system and queries in the leave request form When A’s leave information is reached, and then select Approve, then just change the value of the status field.
This process is very simple, I believe you can think of it.
However, this is a very simple process. Generally speaking, there is no need to use a workflow for such a process, but in reality, the workflows we involve are often very complex. Let me give an example and say Reimbursement approval, this may be experienced by many small partners.
As you can see, this process is relatively complicated. At this time, if you use a status field to describe it, it is difficult to say what is going on. Each step of approval may be approved or rejected. Rejection does not mean the end of the process. After employees modify the reimbursement information, they can continue to submit. At this time, if status is also used to describe, then status will have multiple N values to represent different situations, which is very inconvenient to maintain.
Is this complicated? No, no, let’s take another example of producing a laptop. Suppose the company has developed a new type of laptop. The entire process from development to production may be as follows:
Compared with the above two, this one is more complicated. There are not only serial tasks but also parallel tasks. How to design such a system? Simply describing the state field is obviously not enough. At this time, we have to consider a general and easier-to-maintain solution to implement such a system. This general and easy-to-maintain solution is workflow.
2. Three major workflows
An early workflow is jBPM, an enterprise-level process engine implemented in Java, one of the products developed by JBoss.
The creator of jBPM is Tom Baeyens, who later left JBoss and joined Alfresco, and launched Activiti, an open source workflow system based on jBPM4, while jBPM completely abandoned the code of jBPM4 in the subsequent code. It can also be seen from this process that jBPM later became two jBPM and Activiti due to different opinions during the development process.
However, the drama is that Activiti5 did not take long, and a Camunda was separated from Activiti. Activiti continued to develop, and a Flowable was separated from it. . .
Since the people who developed jBPM, Activiti, Camunda, and Flowable are more or less related, one has to speculate that it is their corporate culture that the people who disagree and go it alone are.
So now there are three mainstream process engines on the market:
- Activiti
- Flowable
- Camunda
All three have their own characteristics:
- Activiti is currently focusing on the cloud, and his current design will be closer to Spring Cloud and Docker.
- The core idea of Flowable is to make a feature-rich process engine tool. In addition to the most basic workflow, it also provides many other extension points. We can implement many of the functions we want based on Flowable (of course, this is also a small partner. One of the reasons why we find Flowable complicated to use).
- Camunda is relatively lightweight compared to the first two. One of the more distinctive features of Camunda is that it provides a small editor based on bpmn.io (Song Ge has already posted about it before). If your project requirements are to be a lightweight, flexible, and highly customizable editor with embedded workflows, you can choose Camunda.
If you compare the differences between these three carefully, you can make a long table. Many people on the Internet have summarized it, so Song Ge will not be verbose here.
3. Flowchart
Since there are three different workflows, are the flowcharts drawn by the three different workflows different?
no.
There is actually a unified standard for the work flow chart, which is BPMN. The full name of BPMN is Business Process Model and Notation, which is translated into Business Process Model and Notation in Chinese. This Chinese is too convoluted, so let’s call it BPMN for short.
This is a set of graphical representations that graphically represent business process models. BPMN was originally developed by the Business Process Management Initiative (BPMI, Business Process Management Initiative). The name.
In a word, there is a very old specification for flowcharts, which is BPMN, and whether it is Activiti, Flowable or Camunda we mentioned earlier, all support this specification, so no matter which process engine you use , you can use the same set of flowcharts.
So what exactly does this specification say?
Let’s take the above flow chart of notebook production as an example to make a brief introduction with our friends:
As can be seen from the above figure, a flow chart mainly includes four aspects:
- event
- connect
- Task
- gateway
Let’s talk one by one.
event
First of all, there should be a start event and an end event in a flowchart, that is, the two circles you see in the picture above. In addition, there are some intermediate events, boundary events, etc. Take an example of an intermediate timing event. For example, after a user places an order, there can be an intermediate timing event that delays delivery by 5 minutes.
connect
A connection is a line that connects events, tasks, gateways, etc. It is usually an ordinary connection. Sometimes the connection has some conditions, such as the leave that Song Ge shared with you in the previous article. If the manager agrees to apply for leave , whichever line is taken, and which line is taken if the manager does not agree with the leave application. Corresponding to the notebook production in the figure above, if the manager approves it, it will load the drawing to prepare for production. If the manager does not approve it, it will be redesigned.
Task
There are actually many categories of tasks.
If subdivided, it can be roughly divided into the following categories:
In the above flowchart, waiting for the completion of the preparation is a receiving task. There is no need to do anything extra in this task. The process stops automatically at this step, and it needs to be manually clicked to push the process to continue downward.
This is typically used to send messages to external parties.
This is generally done automatically by the system. In fact, it is a custom class of ours, which can accomplish what we want to do in a custom class.
An automated activity. When the process executes to the script task, the corresponding script is automatically executed.
BPMN2.0 is newly introduced to interface with the business rule engine, and the business rule task is used to execute one or more rules synchronously.
Used to model work that needs to be done by human actors.
Although there are many sub-categories, but if you look carefully, these types can be classified into two categories:
- User task: Indicates what the human needs to intervene to do. For example, whether to agree or not, or to enter some parameters, in order for humans to complete tasks, a form system is needed to allow humans to input data or display data for people to see. This is why the user task and the form system are combined together. The user task The user needs to submit an action to the engine to complete the task, otherwise the process will pause and wait here.
- Service Task: Represents something that the machine does automatically. The task of calling a service, which can be a Spring JavaBean or a remote REST service, and the process will automatically execute the service task.
Activity
Activities can be regarded as a special kind of task. An activity can call another process to run as a subprocess of the current process. Activities can also be divided into user activities, script activities, and so on. Visually, the activity is a bit deeper than the task border. That’s all.
gateway
If the gateway is subdivided, there are many different types of gateways.
This kind of gateway is also called an exclusive gateway. The gateway in our previous leave process is a mutually exclusive gateway. Such a gateway has one and only one valid exit.
This kind of gateway will have multiple exits, as long as the conditions are met, they will be executed.
An event gateway is driven by an intermediate event, which triggers a decision only after the event it is waiting for has occurred. Event-based gateways allow decisions to be made based on events.
Parallel gateways generally appear in pairs. In the process of producing notebooks above, parallel operations such as production screens and keyboards are implemented through parallel gateways.
Well, these are some basic concepts about process engines. After smoothing out these basic concepts, after looking back at our previous articles about process engines, there should be some different understandings:
#Introduction #concept #minimalist #Java #workflow #Jiangnans #personal #space #News Fast Delivery