Spring Boot + Camunda 8 Integration Example

 Integrating Spring Boot with Camunda 8 allows developers to build scalable, cloud-native workflow applications where business processes (BPMN) are executed by external workers written in Java. In this blog, we’ll walk through a simple end-to-end integration example using Camunda 8, Zeebe, and Spring Boot.


🔹 1. What Changes in Camunda 8?

Unlike Camunda 7, Camunda 8 follows a decoupled architecture:

  • BPMN runs in the Zeebe engine

  • Business logic runs in external Job Workers

  • Spring Boot apps connect via the Zeebe client

  • Communication is event-driven and asynchronous

👉 There is no embedded engine inside Spring Boot in Camunda 8.


🔹 2. Architecture Overview

Flow:

  1. BPMN process deployed to Camunda 8

  2. Service Task creates a Job (with a type)

  3. Spring Boot Job Worker subscribes to that type

  4. Worker executes logic and updates process variables


🔹 3. Prerequisites

  • Java 17+

  • Spring Boot 3+

  • Camunda 8 (Self-Managed or SaaS)

  • Camunda Modeler

  • Maven


🔹 4. Maven Dependency

Add the Camunda 8 Spring Boot starter:

<dependency> <groupId>io.camunda</groupId> <artifactId>spring-boot-starter-camunda</artifactId> </dependency>

This enables:

  • Zeebe client

  • @JobWorker annotation

  • BPMN deployment support


🔹 5. Spring Boot Configuration

Self-Managed Camunda 8 (application.yaml)

camunda: client: mode: self-managed zeebe: gateway-address: 127.0.0.1:26500 auth: enabled: false

👉 For Camunda 8 SaaS, OAuth credentials are required instead.


🔹 6. BPMN Process Configuration

Create a simple BPMN process in Camunda Modeler:

  • Add a Service Task

  • Implementation: Job Worker

  • Type: order-worker

  • Retries: 3

📌 The job type must match the Java worker.


🔹 7. Spring Boot Job Worker Implementation

Example: Order Processing Worker

package com.example.worker; import io.camunda.zeebe.client.api.response.ActivatedJob; import io.camunda.zeebe.spring.client.annotation.JobWorker; import org.springframework.stereotype.Component; import java.util.HashMap; import java.util.Map; @Component public class OrderWorker { @JobWorker(type = "order-worker", autoComplete = true) public Map<String, Object> handle(final ActivatedJob job) { Map<String, Object> vars = job.getVariablesAsMap(); String orderId = (String) vars.get("orderId"); Double amount = ((Number) vars.get("amount")).doubleValue(); // Business logic String status = amount > 1000 ? "APPROVED" : "REVIEW"; Map<String, Object> output = new HashMap<>(); output.put("orderStatus", status); output.put("processedOrderId", orderId); return output; } }

✅ Returning a map automatically updates workflow variables.


🔹 8. Error Handling & Retries

Automatic retry (exception-based)

if (amount == null) { throw new RuntimeException("Amount is missing"); }
  • Retries decrease automatically

  • Incident appears in Operate when retries reach zero


Manual control (autoComplete = false)

@JobWorker(type = "order-worker", autoComplete = false) public void handle(ActivatedJob job) { try { Map<String, Object> out = Map.of("orderStatus", "APPROVED"); job.getClient().newCompleteCommand(job.getKey()) .variables(out) .send() .join(); } catch (Exception e) { job.getClient().newFailCommand(job.getKey()) .retries(job.getRetries() - 1) .errorMessage(e.getMessage()) .send() .join(); } }

🔹 9. Running the Example

  1. Start Camunda 8 (Docker Compose)

  2. Deploy BPMN from Modeler

  3. Start a process instance with variables:

{ "orderId": "ORD-101", "amount": 1500 }
  1. Run Spring Boot application

  2. Verify execution in Operate


🔹 10. Common Integration Issues

❌ Worker not triggered:

  • Job type mismatch

  • Wrong gateway address

  • Worker app not running

  • Missing variables

❌ Serialization issues:

  • Use JSON-friendly data

  • Avoid Java object serialization


✅ Conclusion

Integrating Spring Boot with Camunda 8 enables developers to build modern, scalable workflow systems where processes and business logic are cleanly separated. By using Job Workers, applications become more resilient, cloud-ready, and easier to maintain.

This architecture is ideal for microservices, event-driven systems, and enterprise-grade process automation.


💼 Professional Support Available

If you are facing issues in real projects related to enterprise backend development or workflow automation, I provide paid consulting, production debugging, project support, and focused trainings.

Technologies covered include Java, Spring Boot, PL/SQL, CMS, Azure, and workflow automation (jBPM, Camunda BPM, RHPAM).


Comments

Popular posts from this blog

Scopes of Signal in jBPM

OOPs Concepts in Java | English | Object Oriented Programming Explained

jBPM Installation Guide: Step by Step Setup