Flowable - Fundation
Flowable is a lightweight business process engine written in Java. It is designed to be fast, efficient, and easy to use, making it a popular choice for developers looking to implement workflow and business process management (BPM) solutions.
A simple workflow might look like this:1
2
3
4
5Start
↓
Manager Approval
↓
End
1 |
|
Key Features of Flowable
- BPMN 2.0 Support: Flowable fully supports the BPMN 2.0 standard, allowing developers to model complex business processes using a graphical notation.
- Easy Integration: Flowable is easy to integrate with existing Java applications and frameworks.
- High Performance: Flowable is designed to be fast and efficient, making it suitable for high-volume workflow processing.
- Extensible: Flowable is highly extensible, allowing developers to customize and extend its functionality to meet specific requirements.
Core Concepts
There are a few important concepts to understand first.
ProcessDefinition
A ProcessDefinition is the template of a workflow. It is usually defined in a BPMN file.
For example: Simple Approval Process can be deployed as a reusable process definition.
ProcessInstance
A ProcessInstance is one running instance of a process definition.
For example, if three employees submit approval requests, the same process definition can create three separate process instances.1
2
3
4
5
6ProcessDefinition
|
+-- ProcessInstance #1
+-- ProcessInstance #2
+-- ProcessInstance #3
+-- ProcessInstance #4
Task
A Task represents work that needs to be completed by a user.
For example: Manager Approval, When Flowable reaches a UserTask, it creates a task and waits for a user to complete it.
Execution
An Execution represents the current execution path inside a running process.
For simple workflows, you can think of it as: Where is the workflow currently running?
For parallel workflows, one process instance may contain multiple executions.
Process Variable
Process variables are data used during workflow execution.
For example:1
2
3approved = true
amount = 1000
priority = HIGH
These variables can be used by BPMN gateways and tasks to decide what should happen next.
Important Flowable Services
Flowable provides several Java services for interacting with the workflow engine.
The most important ones for beginners are:1
2
3
4
5
6
7RepositoryService → Process definitions and deployments
RuntimeService → Running process instances
TaskService → User tasks
HistoryService → Completed processes and task history
For example, starting a process can be done with:1
2
3runtimeService.startProcessInstanceByKey(
"simpleApproval"
);
How a Workflow Runs
Consider this workflow:1
2
3
4
5Start
↓
Manager Approval
↓
End
When the process starts, Flowable follows the BPMN definition. Once it reaches Manager Approval, Flowable creates a task and pauses the process.1
2
3
4
5Start
↓
Manager Approval
↓
WAIT
An important point is that Flowable does not keep a Java thread running while waiting for the manager. Instead, it stores the workflow state in the database.
Later, when the manager completes the task:1
taskService.complete(taskId);
Flowable resumes the workflow from where it stopped.1
2
3Manager Approval
↓
End
This makes workflow engines especially useful for business processes that may take hours, days, or even weeks to complete.
Basic Flowable Lifecycle
A useful way to understand the complete lifecycle is:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21BPMN
↓
Deployment
↓
ProcessDefinition
↓
Start
↓
ProcessInstance
↓
Execution
↓
UserTask
↓
Task
↓
Complete
↓
End
↓
History
In Java, the main services roughly map to this lifecycle:1
2
3
4
5Service Responsibility
RepositoryService Process definitions and deployments
RuntimeService Running process instances
TaskService User tasks
HistoryService Historical process information
A Good Starting Point
If you are new to Flowable, start with a very simple BPMN process:1
Start → UserTask → End
Then focus on understanding these four services:1
2
3
4RepositoryService
RuntimeService
TaskService
HistoryService
Once this basic flow is clear, more advanced concepts such as the following become much easier to understand:1
2
3
4
5
6
7
8Process variables
Exclusive gateways
Parallel gateways
Candidate users and groups
Service tasks
Timers
Listeners
Sub-processes
Key Takeaway
The simplest way to think about Flowable is:
BPMN defines how a business process should flow, while Flowable is the engine that executes that process.
UnderstandingProcessDefinition,ProcessInstance,Task,Execution, and the core Flowable services provides a solid foundation for learning more advanced workflow design.




