Backend Development 15 min read

Integrating Camunda 7 Workflow Engine with Spring Boot: Concepts, Configuration, and API 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 schema, process modeling, task types, gateways, and detailed API examples for process and task management.

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

Concepts

Defines key terms such as Process, Process Instance, Variables, Task, and Deployment in the Camunda BPMN context.

Core Components

Describes the Process Engine and the web-based management application provided by Camunda.

API Overview

Provides a link to the official Camunda Process Engine API documentation.

Spring Boot Integration

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>

Database : Uses MySQL; Camunda creates required tables automatically.

POM snippet

<project xmlns="http://maven.apache.org/POM/4.0.0" ...>
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.3</version>
    </parent>
    <groupId>com.example</groupId>
    <artifactId>camunda-demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <properties>
        <java.version>17</java.version>
    </properties>
    <dependencies>
        ... (Camunda and MySQL dependencies) ...
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

application.yml

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

Running the Application

After starting, Camunda’s web console is available at http://localhost:8081/ with the admin credentials defined above. The engine automatically creates the required tables (e.g., ACT_ID_, ACT_HI_, ACT_RE_, ACT_RU_, ACT_GE_).

Process Modeling

Use Camunda Modeler to design BPMN diagrams. The article shows an example OA‑style process with user tasks, service tasks, and various gateways (exclusive, parallel, inclusive).

Task Types

User Task : Requires manual completion via taskService.complete(taskId, variables); .

Service Task : Executed automatically by the engine.

Gateways

Explains exclusive, parallel, and inclusive gateways and how conditions are evaluated using process variables.

API Usage

Process APIs

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

Task APIs

List<Task> tasks = taskService.createTaskQuery().orderByTaskCreateTime().desc().list();
Task activeTask = taskService.createTaskQuery().taskId(taskId).active().singleResult();
List<HistoricTaskInstance> history = historyService.createHistoricTaskInstanceQuery().processInstanceId(instanceId).list();

Variable APIs

runtimeService.setVariable(instance.getId(), "PATIENT_ID", relatedId);
Object var = runtimeService.getVariable(instance.getId(), "GENERAL_ID");
HistoricVariableInstance histVar = historyService.createHistoricVariableInstanceQuery()
    .processInstanceId(instance.getId()).variableName("PATIENT_ID").singleResult();

Listeners and Extensions

Shows how to define TaskListener and ExecutionListener beans using lambda expressions, as well as delegate expressions for JavaDelegate implementations. Also covers extension properties for custom attributes.

Identity and Authorization

Demonstrates setting the authenticated user via identityService.setAuthenticatedUserId(UserUtil.getUserId().toString()); and retrieving it from the engine’s context.

Conclusion

The article ends with a call for readers to like, share, and follow the author’s public account for more advanced Spring Cloud, Spring Boot, and MyBatis tutorials.

JavaBPMNSpring BootWorkflow EngineProcess AutomationCamunda
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.