Spring Boot + Camunda 7 Integration Example

Integrating Spring Boot with Camunda 7 is a popular and stable approach for building Java-based BPM applications. In Camunda 7, the process engine is embedded directly inside the Spring Boot application, allowing synchronous execution of BPMN processes and direct invocation of Java code from Service Tasks.

This blog demonstrates a simple end-to-end integration example using Spring Boot, Camunda 7, BPMN, and Java Service Tasks.


🔹 1. Architecture Overview

In Camunda 7:

  • The BPMN engine runs inside Spring Boot

  • Service Tasks invoke Java classes directly

  • Execution is synchronous

  • Java objects can be used as process variables

  • Transactions are managed by Spring

👉 This architecture is ideal for on-premise systems, monoliths, or internal microservices.


🔹 2. Prerequisites

  • Java 11 or Java 17

  • Spring Boot 2.x

  • Camunda 7.x

  • Maven

  • Camunda Modeler


🔹 3. Maven Dependencies

Add the Camunda 7 Spring Boot starter:

<dependency> <groupId>org.camunda.bpm.springboot</groupId> <artifactId>camunda-bpm-spring-boot-starter</artifactId> </dependency>

(Optional – Camunda Web Apps)

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

This provides:

  • Embedded process engine

  • REST API

  • Cockpit, Tasklist, and Admin


🔹 4. Configuration (application.yaml)

camunda: bpm: admin-user: id: demo password: demo filter: create: All tasks

You can access Camunda apps at:

http://localhost:8080/app

🔹 5. BPMN Service Task Configuration

In Camunda Modeler:

  1. Add a Service Task

  2. Implementation: Java Class

  3. Java Class:

com.example.camunda.service.PaymentService

🔹 6. Java Service Task Implementation

Example using JavaDelegate

package com.example.camunda.service; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; import org.springframework.stereotype.Component; @Component public class PaymentService implements JavaDelegate { @Override public void execute(DelegateExecution execution) { String orderId = (String) execution.getVariable("orderId"); Double amount = (Double) execution.getVariable("amount"); String status = amount > 1000 ? "APPROVED" : "REVIEW"; execution.setVariable("paymentStatus", status); execution.setVariable("processedOrderId", orderId); } }

✅ The code executes inside the same transaction as the BPMN process.


🔹 7. Starting the Process

Using REST API

POST /engine-rest/process-definition/key/order-process/start
{ "variables": { "orderId": { "value": "ORD-101", "type": "String" }, "amount": { "value": 1500, "type": "Double" } } }

🔹 8. Error Handling

Technical Error (Rollback)

throw new RuntimeException("Payment failed");

➡ Rolls back the transaction


BPMN Error (Modeled Flow)

throw new BpmnError("PAYMENT_FAILED");

➡ Caught by a Boundary Error Event in BPMN


🔹 9. Advantages of Spring Boot + Camunda 7

✅ Simple architecture
✅ Embedded engine
✅ Direct Java integration
✅ Strong transactional support
✅ Mature and stable platform


🔹 10. Limitations

❌ Limited horizontal scalability
❌ Tight coupling between process and code
❌ Not cloud-native by design
❌ Migration needed for Camunda 8


✅ Conclusion

The Spring Boot + Camunda 7 integration remains a powerful and reliable solution for Java-based BPM applications. Its embedded engine and direct Java Service Tasks make it easy to develop and maintain business processes.

However, for cloud-native and highly scalable systems, Camunda 8 is the recommended long-term direction.Integrating Spring Boot with Camunda 7 is a popular and stable approach for building Java-based BPM applications. In Camunda 7, the process engine is embedded directly inside the Spring Boot application, allowing synchronous execution of BPMN processes and direct invocation of Java code from Service Tasks.

This blog demonstrates a simple end-to-end integration example using Spring Boot, Camunda 7, BPMN, and Java Service Tasks.


🔹 1. Architecture Overview

In Camunda 7:

  • The BPMN engine runs inside Spring Boot

  • Service Tasks invoke Java classes directly

  • Execution is synchronous

  • Java objects can be used as process variables

  • Transactions are managed by Spring

👉 This architecture is ideal for on-premise systems, monoliths, or internal microservices.


🔹 2. Prerequisites

  • Java 11 or Java 17

  • Spring Boot 2.x

  • Camunda 7.x

  • Maven

  • Camunda Modeler


🔹 3. Maven Dependencies

Add the Camunda 7 Spring Boot starter:

<dependency> <groupId>org.camunda.bpm.springboot</groupId> <artifactId>camunda-bpm-spring-boot-starter</artifactId> </dependency>

(Optional – Camunda Web Apps)

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

This provides:

  • Embedded process engine

  • REST API

  • Cockpit, Tasklist, and Admin


🔹 4. Configuration (application.yaml)

camunda: bpm: admin-user: id: demo password: demo filter: create: All tasks

You can access Camunda apps at:

http://localhost:8080/app

🔹 5. BPMN Service Task Configuration

In Camunda Modeler:

  1. Add a Service Task

  2. Implementation: Java Class

  3. Java Class:

com.example.camunda.service.PaymentService

🔹 6. Java Service Task Implementation

Example using JavaDelegate

package com.example.camunda.service; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; import org.springframework.stereotype.Component; @Component public class PaymentService implements JavaDelegate { @Override public void execute(DelegateExecution execution) { String orderId = (String) execution.getVariable("orderId"); Double amount = (Double) execution.getVariable("amount"); String status = amount > 1000 ? "APPROVED" : "REVIEW"; execution.setVariable("paymentStatus", status); execution.setVariable("processedOrderId", orderId); } }

✅ The code executes inside the same transaction as the BPMN process.


🔹 7. Starting the Process

Using REST API

POST /engine-rest/process-definition/key/order-process/start
{ "variables": { "orderId": { "value": "ORD-101", "type": "String" }, "amount": { "value": 1500, "type": "Double" } } }

🔹 8. Error Handling

Technical Error (Rollback)

throw new RuntimeException("Payment failed");

➡ Rolls back the transaction


BPMN Error (Modeled Flow)

throw new BpmnError("PAYMENT_FAILED");

➡ Caught by a Boundary Error Event in BPMN


🔹 9. Advantages of Spring Boot + Camunda 7

✅ Simple architecture
✅ Embedded engine
✅ Direct Java integration
✅ Strong transactional support
✅ Mature and stable platform


🔹 10. Limitations

❌ Limited horizontal scalability
❌ Tight coupling between process and code
❌ Not cloud-native by design
❌ Migration needed for Camunda 8


✅ Conclusion

The Spring Boot + Camunda 7 integration remains a powerful and reliable solution for Java-based BPM applications. Its embedded engine and direct Java Service Tasks make it easy to develop and maintain business processes.

However, for cloud-native and highly scalable systems, Camunda 8 is the recommended long-term direction.

💼 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