This article takes you to master all business concepts of flowable workflow engine

1. What is workflow approval

According to my understanding, it is approval process management.

2. What is flowable

1. Official interpretation

The official explanation is as follows:

The Flowable project provides a core set of open source business process engines that are compact and efficient. They provide a workflow and business process management (BPM) platform for developers, system administrators, and business users.

Its core is a lightning fast and proven dynamic BPMN process engine, along with DMN decision table and CMMN case management engine, all of which are written in Java. They are open source under the Apache 2.0 license and have a committed community.

All engines can be embedded in Java applications or run as services in servers, clusters and clouds. They can run as independent engines or services, or they can be integrated to provide a rich suite for business process management. They are perfectly integrated with Spring. With their rich Java and rest APIs, they are an ideal basis for orchestrating manual or robotic automated processing. They enable micro service orchestration or soft connect to the micro service itself.

Here is a summary:

  1. The purpose is to manage the business approval workflow.
  2. Use BPMN technology.
  3. It can be easily nested in the spring system.

2. A prominent family

Speaking of flowable, it also comes from activiti. Because the internal staff of activiti are inconsistent, a large number of small partners have made an appointment to start a business. But the pot is still the original pot, but the way of cooking is different. Therefore, there is little difference between flowable and activiti in thought. It's just more powerful.

3. What is BPMN

1. Explain BPMN

The official explanation is as follows:

The standard business process model and notation (BPMN) will provide enterprises with the ability to understand their internal business processes with graphical symbols, and enable organizations to communicate these processes in a standard way. In addition, graphical symbols will help to understand performance collaboration and business transactions between organizations. This will ensure that enterprises understand themselves and business participants, and enable organizations to quickly adapt to the new internal and B2B business environment.

Here is a summary:

  1. BPMN has developed a set of standard business process modeling symbols. The following figure is the symbol of modeling.

  1. BPMN defines a flowchart written using the above symbols. The following figure is a diagram drawn through BPMN rules.

To put it bluntly, the rule diagram shown in the figure above is the BPMN flow chart.

2. Common symbols of BPMN

1. Start node

Indicates where to start the process.

2. Task node

It contains many tasks, as shown in the figure. One of the most commonly used is user tasks. This option is required for all specified approvers.

3. Gateway components

Gateway is equivalent to judgment (and, or, not). The three most commonly used gateways are mutually exclusive / exclusive gateway, parallel gateway and compatible gateway.

  1. Mutually exclusive gateway: equivalent to judgment. For example, if the input value is greater than 20 nodes A and less than 20 nodes B.

  1. Parallel gateways: compatible gateways appear in pairs, indicating that all people in the gateway agree to enter the next node.

3. Compatible gateway: the combination of mutually exclusive gateway and parallel gateway. If both a and B are mutually exclusive, they need to flow. If only one is satisfied, only those that meet the conditions will flow.

3. Give an example

The description is as follows:

  1. Enter the approval stage after the submission of the approval applicant
  2. Two project managers need to approve and enter the next node after both agree.
  3. Managers can approve. Anyone whose business here is a manage r position can approve. (there is claim business here, not described here)
  4. Here, the approval of the General Manager / chairman is required if it is more than 20 days, and the approval of the general manager if it is less than 20 days.

4. Why choose flowable

In terms of technology selection, flowable is newer and more complete than activiti. In order to use the new instead of the old, it is recommended to use flowable. But compared with activiti, his online documents are very few. Getting started is also more difficult.

Of course, you can develop your own approval process system and design the fields of submitter and approver, which can be completed through sql query. This is the most time-consuming and laborious method, and there is no functional comparability with open source architecture. Moreover, open source flowable/activiti has formed its own system. When talking with customers, it highlights the professionalism of the system.

5. Common business processes

The standard approval process system has a set of standardized business processes. The following describes how to operate the approval process system.

1. Overall process

The business process is mainly divided into the following steps:

Generally, the module names in the system are as follows, please correspond to each other.

Task management here can view the specific information of each approval node of a process. Non essential business.

1. Editing process

This part is mainly about the production process.

1. Custom form

When the applicant approves, it is necessary to fill in the applied items and application data. If leave approval is required, leave time and leave reason shall be filled in. So we hope this form can be customized.

2. Edit process model

That is, BPMN is used to draw a flow chart, in which the form of the approval process, the personnel of the next approval node and the flow conditions entering the process will be specified.

Of course, you can also import a flowchart. At the same time, you can specify the form that the applicant needs to fill in when applying. (if the approver needs to add an approval form, it can also be configured here)

3. Deploy to process definition

The process model will not take effect after editing / importing. After that, the generated process definition can be used and approved. Of course, the process definition module also has functions such as export and activation.

2. Implementation approval

1. Function list

After designing the process, you can initiate and approve. Users have the following functions.

2. Functional interpretation

Reject: send approval reset to a node for re approval.

Transfer to: A transfers it to B for approval. After B approves, it enters the next node.

Delegate: a transfers it to B for approval. After B approves, it transfers it to A. after a approves, it enters the next node.

3. Query process instances and tasks

As can be seen from the above figure, process instances will be generated after approval is initiated. Process instance and task management can view the initiated approval.

  1. Each set of approval information generates a process instance information.
  2. A process instance has multiple approval nodes (drawn in the flowchart), and each approval node is a piece of task management information.

Note the process definition and process instance concepts.

6. How to develop

In fact, flowable is very simple, but because there is less information on the market and less understanding, it is difficult for the technology stack to circulate.

flowable provides us with 47 tables and 7 common APIs.

1. Table provided

All database tables of Flowable are represented by ACT_ start. The second part is a two character identifier that explains the purpose of the table. The naming of service API s also roughly conforms to this rule.

    1. ACT_RE_*: 'RE 'stands for repository. The table with this prefix contains "static" information, such as process definitions and process resources (pictures, rules, etc.).
    1. ACT_RU_*: 'RU 'stands for runtime. These tables store runtime information, such as process instance, user task, variable, job, and so on. Flowable saves run-time data only in the process instance run, and deletes records at the end of the process instance. This ensures that the runtime table is small and fast.
    1. ACT_ HI_*: ' 'Hi' stands for history. These tables store historical data, such as completed process instances, variables, tasks, and so on.
    1. ACT_GE_*: General data. Use in multiple places.
    1. ACT_ID_*: Represents organizational information, such as users, user groups, and so on. (rarely used)
    1. FLW_*. No official description was found and the table is empty.


  • ACT_ GE_ Byte array: save the xml of bpmn of the process and the Image thumbnail of the process
  • ACT_GE_PROPERTY: basic information related to Flowable. For example, the version information used by each module.


  • ACT_RE_DEPLOYMENT: deployment object, storage process name
  • ACT_RE_MODEL: process based model information
  • ACT_RE_PROCDEF: process definition table


  • ACT_RU_ACTINST: active table of running instances
  • ACT_RU_DEADLETTER_JOB: when a JOB cannot be executed many times, it will be recorded in this table
  • ACT_RU_ENTITYLINK: not used yet. Update this table later.
  • ACT_ RU_ EVENT_ Subscrir: runtime events
  • ACT_RU_EXECUTION: running instance table
  • ACT_RU_HISTORY_JOB´╝Ť Running scheduled task history table
  • ACT_RU_IDENTITYLINK: information of the current task executor
  • ACT_RU_JOB: running asynchronous task
  • ACT_RU_SUSPENDED_JOB: suspended task table. If an asynchronous task is running, it is suspended. Will be recorded in the thesaurus
  • ACT_RU_TASK: normal node task in operation
  • ACT_RU_TIMER_JOB: scheduled job table
  • ACT_RU_VARIABLE: process instance variable in operation


  • ACT_ID_GROUP: user group information
  • ACT_ID_INFO: user details
  • ACT_ID_MEMBERSHIP: relationship between user groups and users
  • ACT_ID_PRIV: permissions
  • ACT_ID_PRIV_MAPPING: relationship between user groups and permissions
  • ACT_ID_PROPERTY: user or user group attribute expansion table
  • ACT_ID_TOKEN: log in to relevant logs
  • ACT_ID_USER: user


  • ACT_HI_ACTINST: process instance history
  • ACT_HI_ATTACHMENT: the historical attachment of the instance, which can hardly be used, will increase a large loading of the database
  • ACT_HI_COMMENT: historical comment of the instance
  • ACT_HI_DETAIL: instance process details
  • ACT_HI_IDENTITYLINK: the history generated if the target person is specified in the instance node
  • ACT_HI_PROCINST: process instance history
  • ACT_HI_TASKINST: task history of the process instance
  • ACT_ HI_ Variant: variable history of the process instance


  • FLW_CHANNEL_DEFINITION: pool pipe definition table
  • FLW_EVENT_DEFINITION: event definition
  • FLW_EVENT_DEPLOYMENT: event required
  • FLW_EVENT_RESOURCE: resource required by the event
  • FLW_EV_DATABASECHANGELOG: Records executed by Liquibase
  • FLW_ EV_ Databasechangelock: Liquibase execute lock
  • FLW_RU_BATCH: temporarily unknown
  • FLW_RU_BATCH_PART: temporarily unknown

2. Interface api provided

flowable provides seven common APIs, which correspond to all the above logic, so as long as you master these APIs, you can complete the development of approval business.


Form data management.

formService.getStartFormKey()  Get form key
formService.getRenderedStartForm()query form  json((no data)
Copy code


Provides APIs for editing and publishing approval processes. Mainly business APIs for model management and process definition.

1.Provides the process definition of query model with conditions api
For example:
repositoryService.createModelQuery().list() Model query 
repositoryService.createProcessDefinitionQuery().list() Process definition query

repositoryService.createXXXXQuery().XXXKey(XXX) (Query this key (exists)

2.Provides a general method for defining large wave models and processes
 Model correlation
repositoryService.getModel()  (Get model)
repositoryService.saveModel()  (Save model)
repositoryService.deleteModel() (Delete model)
repositoryService.createDeployment().deploy(); (Deployment model)
repositoryService.getModelEditorSource()  (Obtain model JSON Data UTF8 (string)
repositoryService.getModelEditorSourceExtra()  (obtain PNG Format (image)

3.Process definition related
repositoryService.getProcessDefinition(ProcessDefinitionId);  Get process definition details
repositoryService.activateProcessDefinitionById() Activate process definition
repositoryService.suspendProcessDefinitionById()  Suspended process definition
repositoryService.deleteDeployment()  Delete process definition
repositoryService.getProcessDiagram()Get process definition picture flow
repositoryService.getResourceAsStream()Get process definition xml flow
repositoryService.getBpmnModel(pde.getId()) obtain bpmn Object (used by the flowchart of the node currently in progress)

4.Process definition authorization related
repositoryService.getIdentityLinksForProcessDefinition() Process definition authorization list
repositoryService.addCandidateStarterGroup()Add group process authorization
repositoryService.addCandidateStarterUser()Add user process authorization
repositoryService.deleteCandidateStarterGroup() Delete group process authorization
repositoryService.deleteCandidateStarterUser()  Delete user process authorization
 Copy code


Process a running process.

runtimeService.createProcessInstanceBuilder().start() Initiating process
runtimeService.deleteProcessInstance() Delete a running process
runtimeService.suspendProcessInstanceById() Suspended process definition
runtimeService.activateProcessInstanceById() Activate process instance
runtimeService.getVariables(processInstanceId); Get the value filled in the form
runtimeService.getActiveActivityIds(processInstanceId)Get the flowchart node for (the flowchart used by the node currently in progress)

runtimeService.createChangeActivityStateBuilder().moveExecutionsToSingleActivityId(executionIds, endId).changeState(); Termination process
 Copy code


After the user initiates approval, a process instance will be generated. historyService is an api for processing process instances, but it includes completed and unfinished process instances.

historyService.createHistoricProcessInstanceQuery().list() Query process instance list (historical process),(including unfinished)
historyService.createHistoricProcessInstanceQuery().list().foreach().getValue() You can get information about forms in history
historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); eradicate id Query process instance
historyService.deleteHistoricProcessInstance() Delete historical process
historyService.deleteHistoricTaskInstance(taskid); Delete task instance
historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId).list()  Process instance node list (used by the flowchart of the node currently in progress)
Copy code

If you are working with a running process instance, use runtimeService.


Approve each node of a process instance.

Node approval of circulation
taskService.createTaskQuery().list() To do list
taskService.createTaskQuery().taskId(taskId).singleResult();  To do task details
taskService.saveTask(task); Modify task
taskService.setAssignee() Set approver
taskService.addComment() Set approval comments
taskService.complete() Complete current approval
taskService.getProcessInstanceComments(processInstanceId); View task details (i.e. who has approved them and what are their opinions)
taskService.delegateTask(taskId, delegater); Delegate tasks
taskService.claim(taskId, userId);Claim task
taskService.unclaim(taskId); Cancel claim
taskService.complete(taskId, completeVariables); Complete the task

taskService.addGroupIdentityLink()Add group task authorization
taskService.addUserIdentityLink() New human task authorization
taskService.deleteGroupIdentityLink() Delete group delegation
taskService.deleteUserIdentityLink() Delete human task authorization
 Copy code


It mainly executes custom commands.

managementService.executeCommand(new classA())  implement classA Internal method of 
Copy code

In the custom method, you can use the following method to obtain the repository service.

ProcessEngineConfiguration processEngineConfiguration =
RepositoryService repositoryService = processEngineConfiguration.getRepositoryService();
Copy code

You can also get the process definition method collection.

ProcessEngineConfigurationImpl processEngineConfiguration =
        ProcessDefinitionEntityManager processDefinitionEntityManager =
as findById/findLatestProcessDefinitionByKey/findLatestProcessDefinitionByKeyAndTenantId Wait.
Copy code


It is used to obtain and save identity information. Here, it is mainly used to obtain identity information.

identityService.createUserQuery().userId(userId).singleResult();  Get the specific information of the approval user
identityService.createGroupQuery().groupId(groupId).singleResult(); Get the specific information of the approval group
 Copy code

Author: little yellow chicken 1992
Source: rare earth Nuggets
The copyright belongs to the author. For commercial reprint, please contact the author for authorization, and for non-commercial reprint, please indicate the source.

Tags: Java Spring Flowable

Posted on Sun, 17 Oct 2021 23:16:02 -0400 by sstangle73