Master Flowable: Deploy, Model, and Integrate a Complete Workflow Engine
This guide walks you through downloading Flowable 6.6.0, deploying the UI on Tomcat, designing a leave‑approval process with events, gateways and user tasks, exporting the BPMN file, setting up a Spring Boot backend, configuring the database, and using Flowable’s core services and APIs with sample code.
1. Deploy flowable‑ui
Download Flowable 6.6.0 from the official site, extract the flowable‑ui.war file and place it in Tomcat's webapps directory. Start Tomcat and open http://localhost:8080/flowable‑ui, then log in with the default account admin/test. Edit flowable‑default.properties to point to a local MySQL database.
2. Model the process
In the Flowable UI, open APP.MODELER and create a leave‑approval workflow. Define start and end events, sequence flows, exclusive gateways, and user tasks for student, teacher, and principal. After modeling, export the BPMN file for later deployment.
Diagram details
Event : start/end nodes.
Sequence flow : connectors between elements.
Gateway : decision points (diamond shape).
User task : human tasks (rectangle).
Exported BPMN XML:
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" ...>
<process id="leave_approval" name="请假审批" isExecutable="true">
<startEvent id="start" name="开始" flowable:initiator="startuser" flowable:formFieldValidation="true"/>
<userTask id="stu_task" name="学生" flowable:candidateGroups="stu_group" flowable:formFieldValidation="true"/>
<sequenceFlow id="flow1" sourceRef="start" targetRef="stu_task"/>
...
</process>
</definitions>3. Backend project setup
Create a Spring Boot 2.3.0 project (JDK 8) and add the following dependencies:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.0.RELEASE</version>
</parent>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-spring-boot-starter</artifactId>
<version>6.6.0</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.45</version>
</dependency>Configure the datasource in application.yml:
spring:
datasource:
url: jdbc:mysql://localhost:3306/flowable?useSSL=false&characterEncoding=UTF-8&serverTimezone=GMT%2B8
driver-class-name: com.mysql.jdbc.Driver
username: root
password: 1234564. Database tables
All Flowable tables start with ACT_. The second part indicates the purpose: ACT_RE_: repository tables (static definitions, resources). ACT_RU_: runtime tables (process instances, tasks, variables, jobs). ACT_HI_: history tables (completed instances, variables, tasks). ACT_GE_: generic tables used in multiple contexts.
Key tables include act_ge_bytearray, act_hi_procinst, act_ru_task, act_id_user, etc.
5. Engine API and services
Important services:
RepositoryService : manage deployments and process definitions.
RuntimeService : start new process instances.
IdentityService : manage users and groups.
FormService : optional form handling.
HistoryService : query historic data.
ManagementService : low‑level DB and job management.
DynamicBpmnService : modify deployed processes without redeployment.
Sample Java code demonstrates deployment, starting a process, claiming and completing tasks for student and teacher groups, and querying historic process and task instances.
import lombok.extern.slf4j.Slf4j;
import org.flowable.engine.*;
import org.flowable.task.api.Task;
import org.springframework.beans.factory.annotation.Autowired;
@Slf4j
public class TestFlowable {
@Autowired private RepositoryService repositoryService;
@Autowired private RuntimeService runtimeService;
@Autowired private HistoryService historyService;
@Autowired private org.flowable.engine.TaskService taskService;
@Autowired private org.flowable.engine.IdentityService identityService;
public void createDeploymentZip() {
// Deploy BPMN zip
try {
File zip = new File("f:/leave_approval.bpmn20.zip");
ZipInputStream zipStream = new ZipInputStream(new FileInputStream(zip));
Deployment deployment = repositoryService.createDeployment()
.addZipInputStream(zipStream)
.deploy();
log.info("Deployment successful:{}", deployment.getId());
} catch (FileNotFoundException e) { e.printStackTrace(); }
// Start process instance
String processKey = "leave_approval";
String businessKey = "schoolleave";
ProcessInstance instance = runtimeService.startProcessInstanceByKey(processKey, businessKey, new HashMap<>());
log.info("Process started:{}", instance.getId());
// Student tasks
List<Task> studentTasks = taskService.createTaskQuery()
.taskCandidateGroup("stu_group")
.orderByTaskCreateTime().desc()
.list();
for (Task task : studentTasks) {
taskService.claim(task.getId(), "my");
taskService.complete(task.getId());
}
// Teacher tasks with decision variable
List<Task> teacherTasks = taskService.createTaskQuery()
.taskCandidateGroup("te_group")
.orderByTaskCreateTime().desc()
.list();
for (Task task : teacherTasks) {
taskService.claim(task.getId(), "myte");
Map<String, Object> vars = new HashMap<>();
vars.put("command", "agree");
taskService.complete(task.getId(), vars);
}
// History queries
List<HistoricProcessInstance> historicProcesses = historyService
.createHistoricProcessInstanceQuery()
.processDefinitionKey("leave_approval")
.list();
List<HistoricTaskInstance> historicTasks = historyService
.createHistoricTaskInstanceQuery()
.processDefinitionKey("leave_approval")
.list();
}
}6. References
Flowable documentation translation: https://github.com/qiudaoke/flowable-userguide
Official Flowable demo for version 6.6.0
Blog post: https://www.cnblogs.com/yangjiming/p/10938515.html
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Programmer DD
A tinkering programmer and author of "Spring Cloud Microservices in Action"
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
