Spring Boot + Kafka + Camunda 8 Project Example

 Modern microservices architectures rely heavily on event-driven communication. In this article, we will build a real example project combining:

  • Spring Boot

  • Apache Kafka

  • Camunda 8

This project demonstrates how to:

  • Start a workflow from a Kafka event

  • Publish Kafka events from Camunda

  • Handle asynchronous orchestration

  • Maintain clean separation of concerns


🎯 Use Case: Order Processing System

Scenario:

  1. An Order Service publishes an event to Kafka.

  2. A Kafka Consumer receives the event.

  3. Camunda 8 starts a workflow.

  4. The workflow triggers a Payment Service.

  5. Payment result is published back to Kafka.

  6. Camunda correlates the message and completes the process.


🏗 Architecture Overview


Components:

  • Spring Boot App

  • Kafka Broker

  • Camunda 8 (Zeebe)

  • Payment Worker


🛠 Step 1: Project Setup

Create Spring Boot project with:

Dependencies:

  • Spring Web

  • Spring Kafka

  • Camunda Zeebe Client

  • Lombok


📦 Maven Dependencies

<dependency> <groupId>io.camunda</groupId> <artifactId>zeebe-client-java</artifactId> <version>8.x.x</version> </dependency> <dependency> <groupId>org.springframework.kafka</groupId> <artifactId>spring-kafka</artifactId> </dependency>

🚀 Step 2: Start Camunda 8 (Local)

Use Docker:

docker compose up

Or connect to Camunda SaaS.


📨 Step 3: Kafka Producer (Order Event)

@Service @RequiredArgsConstructor public class OrderProducer { private final KafkaTemplate<String, String> kafkaTemplate; public void sendOrder(String orderJson) { kafkaTemplate.send("order-created", orderJson); } }

📥 Step 4: Kafka Consumer → Start Camunda Process

@KafkaListener(topics = "order-created") public void consume(String message) { zeebeClient.newCreateInstanceCommand() .bpmnProcessId("order-process") .latestVersion() .variables(message) .send() .join(); }

This starts the workflow.


📊 Step 5: BPMN Model

Basic BPMN Flow:


Service Task type: process-payment


🔄 Step 6: Job Worker → Publish Payment Event

@JobWorker(type = "process-payment") public void processPayment(ActivatedJob job) { kafkaTemplate.send("payment-request", job.getVariables()); jobClient.newCompleteCommand(job.getKey()) .send() .join(); }

🔔 Step 7: Payment Service → Publish Result

@KafkaListener(topics = "payment-request") public void processPayment(String message) { kafkaTemplate.send("payment-completed", message); }

🔗 Step 8: Kafka → Correlate Message to Camunda

@KafkaListener(topics = "payment-completed") public void correlate(String message) { zeebeClient.newPublishMessageCommand() .messageName("PaymentCompleted") .correlationKey(extractOrderId(message)) .variables(message) .send() .join(); }

⚠ Important Production Considerations

1️⃣ Idempotency

Kafka may deliver duplicates.
Always ensure process instances are unique by business key.


2️⃣ Retry Strategy

Use:

  • Zeebe retry mechanism

  • Kafka retry topics

  • Dead letter queue


3️⃣ Error Handling

Use BPMN:

  • Boundary error events

  • Incident monitoring


4️⃣ Monitoring

Monitor:

  • Kafka lag

  • Zeebe backpressure

  • Job failure rate


🧠 Why This Architecture Works

  • Kafka handles high-volume events.

  • Camunda handles business orchestration.

  • Spring Boot keeps services modular.

  • Each component scales independently.

This is a clean enterprise-grade pattern.


📌 Final Thoughts

This example shows how to combine:

  • Event streaming (Kafka)

  • Workflow orchestration (Camunda 8)

  • Business logic (Spring Boot)

This architecture is widely used in:

  • FinTech

  • E-commerce

  • Logistics

  • Enterprise SaaS

💼 Need Help with Camunda, Jira, or Enterprise Workflows?

I help teams solve real production issues and build scalable systems.

Services I offer:
• Camunda & BPMN workflow design and debugging  
• Jira / Confluence setup and optimization  
• Java, Spring Boot & microservices architecture  
• Production issue troubleshooting  


📩 Email: ishikhanirankari@gmail.com | info@realtechnologiesindia.com

✔ Available for quick consulting calls and project-based support
✔ Response within 24 hours


🎥 Learn IT with Shikha on YouTube

Prefer learning through videos? Watch practical tutorials on Kafka, Camunda, Alfresco, Java, Spring Boot, Microservices and Enterprise Architecture.

▶ Subscribe to Learn IT with Shikha on YouTube

Comments

Popular posts from this blog

Top 50 Camunda BPM Interview Questions and Answers for Developers (2026 Guide)

10 BPMN Best Practices Every Camunda Developer Should Know

OOPs Concepts in Java | English | Object Oriented Programming Explained