Skip to content

challamani/camunda-java-integration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Camunda 8 and Spring Boot 3.x integration examples

This repo contains a sample Spring Boot application that demonstrates how to integrate with Camunda 8 using the Zeebe client. It includes examples of external service tasks and receive tasks, showcasing how to interact with the Camunda engine from a Spring Boot application.

Prerequisites

version

  • Default build/runtime: Java 21
  • Optional fallback: Java 17 via Maven profile java17
  • Camunda 8 (Zeebe) instance running locally or remotely
  • Spring Boot 3.x application with Zeebe client dependency

Start Camunda 8 instance

Download the latest - https://docs.camunda.io/docs/self-managed/quickstart/developer-quickstart/c8run/ Run:

  cd c8run-8* && ./start.sh

Install Camunda Modeler

Install Camunda Modeler

Exploring the Camunda 8 Rest APIs to deploy and start the process

  • Deploy the BPMN process definition using Camunda Rest API

Request:

  curl -X POST http://localhost:8080/v2/deployments \
    -H "Content-Type: multipart/form-data" \
    -F "resources=@./src/main/resources/order-process-v2.bpmn"

Response:

{
  "tenantId": "<default>",
  "deploymentKey": "2251799813693661",
  "deployments": [
    {
      "processDefinition": {
        "processDefinitionId": "OrderProcessDefinition_v2",
        "processDefinitionVersion": 1,
        "resourceName": "order-process-v2.bpmn",
        "tenantId": "<default>",
        "processDefinitionKey": "2251799813693662"
      }
    }
  ]
}
  • Start a process using curl command
curl -X POST http://localhost:8080/v2/process-instances \
  -H "Content-Type: application/json" \
  -d '{
    "processDefinitionId": "OrderProcessDefinition_v2",
    "variables": {
      "orderId": "ORDER-001"
    }
  }'

Response:

{
  "processDefinitionId": "OrderProcessDefinition_v2",
  "processDefinitionVersion": 1,
  "tenantId": "<default>",
  "variables": {},
  "processDefinitionKey": "2251799813693662",
  "processInstanceKey": "2251799813695002",
  "tags": []
}

Process REST Endpoints

Start Process Instance

Endpoint: POST /api/processes/start

Start a new process instance with variables using the Java Client:

curl -X POST http://localhost:8082/api/processes/start \
  -H "Content-Type: application/json" \
  -d '{
    "processDefinitionId": "OrderProcessDefinition_v2",
    "variables": {
      "orderId": "ORDER-001"
    }
  }'

Response:

{
  "processInstanceKey": 2251799813695002,
  "processDefinitionId": "OrderProcessDefinition_v2",
  "processDefinitionVersion": 1,
  "status": "ACTIVE"
}

Publish Message

Endpoint: POST /api/processes/publish-message

Publish a message to correlate with process instances using the Java Client:

curl -X POST http://localhost:8082/api/processes/publish-message \
  -H "Content-Type: application/json" \
  -d '{
    "messageName": "Message_Confirmation",
    "correlationKey": "ORDER-001",
    "variables": {
      "approvedBy": "admin"
    },
    "timeToLive": 300000
  }'

Response:

{
  "messageName": "Message_Confirmation",
  "correlationKey": "ORDER-001",
  "status": "PUBLISHED",
  "message": "Message published successfully"
}

Process Flow

  1. Start process via /api/processes/start → Process waits at Receive Task
  2. External service tasks execute via Job Workers (inventoryAllocation, packingQueue, deliveryQueue)
  3. Publish message via /api/processes/publish-message → Token advances and service tasks execute
  4. On quality check success → Process completes
  5. On quality check failure → Manual Review user task remains active

Note: Service task execution relies on active Job Workers (see OrderProcessHandler.java). No mocking required for Job Workers in deployment.

camunda-process-screenshot.png

Gatling Load Testing Module

A standalone Gatling module is available at gatling-load-tests to run a chained flow load test for:

  1. POST /api/processes/start
  2. POST /api/processes/publish-message

Run it with:

mvn -f gatling-load-tests/pom.xml gatling:test

You can configure request volume and timings via JVM properties, for example:

mvn -f gatling-load-tests/pom.xml gatling:test \
  -Dusers=25 \
  -DrampSeconds=10 \
  -DpauseMillis=50

See gatling-load-tests/README.md for all properties.

About

You can find some sample external worker implementation using camunda-external-task-client

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages