Operations 25 min read

Understanding Flowable Gateways, Process Variables, and Historical Process Queries

This article provides a comprehensive tutorial on Flowable BPMN, covering the three main gateway types, various methods for setting global, local, and transient process variables, and detailed techniques for querying historical process information, tasks, activities, variables, logs, and identity links.

Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
Understanding Flowable Gateways, Process Variables, and Historical Process Queries

Flowable includes three common gateway types—exclusive, parallel, and inclusive—each with distinct behavior for directing process flow based on conditions or concurrency.

Exclusive Gateway allows multiple incoming paths but only one outgoing path, typically used for conditional branching. Example configurations show how to set a days variable and define conditions such as ${days<=1} to route to specific approval tasks.

Parallel Gateway splits the flow into concurrent paths and later synchronizes them, as illustrated by a notebook production process where screen and keyboard assembly occur in parallel before final assembly.

Inclusive Gateway can act as either exclusive or parallel based on runtime conditions, demonstrated with a reimbursement approval scenario where different approval combinations are triggered by the amount.

The article then explains four ways to set process variables:

Setting variables at process start using a map of key‑value pairs.

Setting variables via task service after the process has started.

Setting variables when completing a task.

Using the runtime service to set variables on an execution.

Variables are categorized as:

Global variables —available throughout the entire process instance.

Local variables —scoped to a specific task and removed after task completion.

Transient variables —not persisted to the database, used only during execution.

Code examples demonstrate each method, for instance:

@Test
void test01() {
    Map
variables = new HashMap<>();
    variables.put("days", 3);
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("demo01", variables);
    logger.info("id:{},activityId:{}", pi.getId(), pi.getActivityId());
}

Historical data can be queried using Flowable's history service. Examples include retrieving finished process instances, historic tasks, activities, variables, and identity links, as well as constructing a comprehensive process instance history log with .includeActivities() , .includeTasks() , and .includeVariables() options.

SQL queries generated by these API calls are shown, illustrating how Flowable maps high‑level queries to tables such as ACT_HI_PROCINST , ACT_HI_TASKINST , ACT_HI_ACTINST , ACT_HI_VARINST , and ACT_HI_IDENTITYLINK . The article also discusses configuring the history level (none, activity, audit, full) to control the amount of data persisted.

BPMNFlowableGatewaysHistorical QueriesProcess Variables
Rare Earth Juejin Tech Community
Written by

Rare Earth Juejin Tech Community

Juejin, a tech community that helps developers grow.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.