Backend Development 14 min read

Integrating Camunda 7 Workflow Engine with Spring Boot: Concepts, Configuration, and Usage

This article explains how to integrate the Camunda 7 workflow engine into a Spring Boot project, covering core concepts, required Maven dependencies, configuration files, database setup, process modeling, task types, gateways, and essential APIs for managing processes, tasks, and variables.

Code Ape Tech Column
Code Ape Tech Column
Code Ape Tech Column
Integrating Camunda 7 Workflow Engine with Spring Boot: Concepts, Configuration, and Usage

The article introduces the Camunda 7 workflow engine as the chosen solution for designing business processes within a Spring Boot application, assuming readers are already familiar with Camunda basics.

Key Concepts such as Process (BPMN definition), Process Instance, Variables, Task, and Deployment are defined, followed by the core components: the Process Engine and the web-based management console.

API Overview points to the official Camunda API documentation (https://docs.camunda.org/manual/7.18/user-guide/process-engine/process-engine-api/) for further reading.

Spring Boot Integration requires three Maven dependencies:

<dependency>
    <groupId>org.camunda.bpm.springboot</groupId>
    <artifactId>camunda-bpm-spring-boot-starter</artifactId>
    <version>7.18.0</version>
</dependency>
<dependency>
    <groupId>org.camunda.bpm.springboot</groupId>
    <artifactId>camunda-bpm-spring-boot-starter-rest</artifactId>
    <version>7.18.0</version>
</dependency>
<dependency>
    <groupId>org.camunda.bpm.springboot</groupId>
    <artifactId>camunda-bpm-spring-boot-starter-webapp</artifactId>
    <version>7.18.0</version>
</dependency>

The project uses MySQL as the database; Camunda will automatically create the required tables on startup. A sample application.yml configures the server port, Camunda admin credentials, and MySQL connection details.

server:
  port: 8081

camunda.bpm:
  admin-user:
    id: admin
    password: 123456
    firstName: yu
    filter:
      create: All tasks

spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:8101/camunda
    username: root
    password: 123456
    type: com.mysql.cj.jdbc.MysqlDataSource

After building and running the application, the Camunda web console is accessible at http://localhost:8081/ with the configured admin credentials. The automatically generated database tables (e.g., ACT_ID_, ACT_HI_*, ACT_RE_*, ACT_RU_*, ACT_GE_*) are listed and briefly described.

Process Modeling is performed with the Camunda Modeler. A sample BPMN file ( test_1.bpmn ) is placed in src/main/resources/bpmn and automatically deployed on application startup.

The article distinguishes two common task types:

User Task – requires manual completion, e.g., taskService.complete(taskId, variables);

Service Task – executed automatically by the engine.

Gateways (exclusive, parallel, inclusive) are explained with simple decision logic based on process variables.

API Usage includes examples for creating, suspending, activating, and deleting processes, querying tasks and process definitions, handling historic data, and managing process variables:

ProcessInstance instance = runtimeService.startProcessInstanceByKey(processKey, params);
runtimeService.suspendProcessInstanceById(instance.getId());
runtimeService.activateProcessInstanceById(instance.getId());
runtimeService.deleteProcessInstance(instance.getId(), "manual delete");

List<Task> tasks = taskService.createTaskQuery().orderByTaskCreateTime().desc().list();
Object var = runtimeService.getVariable(instance.getId(), "myVar");
runtimeService.setVariable(instance.getId(), "myVar", value);

List<HistoricProcessInstance> historic = historyService.createHistoricProcessInstanceQuery().list();

Task listeners and execution listeners are shown as Spring beans that can modify variables or perform custom logic during task or process events.

IdentityService is used to set the authenticated user for audit purposes:

identityService.setAuthenticatedUserId(UserUtil.getUserId().toString());
Authentication auth = identityService.getCurrentAuthentication();

Overall, the article provides a step‑by‑step guide for developers to embed Camunda workflow capabilities into a Spring Boot microservice, covering configuration, deployment, database schema, process modeling, task handling, and extensibility through listeners and custom Java delegates.

JavaworkflowBPMNSpring Bootprocess-engineCamunda
Code Ape Tech Column
Written by

Code Ape Tech Column

Former Ant Group P8 engineer, pure technologist, sharing full‑stack Java, job interview and career advice through a column. Site: java-family.cn

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.