0
0
Kafkadevops~30 mins

Event choreography vs orchestration in Kafka - Hands-On Comparison

Choose your learning style9 modes available
Event Choreography vs Orchestration with Kafka
📖 Scenario: Imagine you are building a simple online store system where different services communicate using Kafka events. You want to understand the difference between event choreography and orchestration by implementing both approaches.
🎯 Goal: Build two simple Kafka event-driven flows: one using event choreography where services react to events independently, and one using orchestration where a central controller manages the flow.
📋 What You'll Learn
Create Kafka topics for order events
Set up event producers and consumers
Implement event choreography with independent consumers
Implement event orchestration with a central orchestrator service
Print messages showing the flow of events
💡 Why This Matters
🌍 Real World
Event-driven systems like online stores, payment processing, and microservices often use Kafka to communicate asynchronously.
💼 Career
Understanding event choreography and orchestration helps you design scalable, maintainable distributed systems and work effectively with Kafka in real jobs.
Progress0 / 4 steps
1
Create Kafka topics and initial order event
Create a Kafka topic called orders and produce an initial order event with the key order-123 and value {"status": "created"}.
Kafka
Need a hint?

Use KafkaProducer to send a JSON event with key order-123 to the orders topic.

2
Set up a configuration variable for event status to listen for
Create a variable called listen_status and set it to created to filter events with this status.
Kafka
Need a hint?

Just create a variable named listen_status and assign the string 'created' to it.

3
Implement event choreography consumer reacting to 'created' events
Write a Kafka consumer that listens to the orders topic and prints Order {key} received with status {status} only if the event's status matches the listen_status variable.
Kafka
Need a hint?

Use KafkaConsumer to read from orders. Decode the key and value, check if status matches listen_status, then print the message.

4
Print the final message showing event choreography output
Print the exact message Order order-123 received with status created to show the event choreography flow.
Kafka
Need a hint?

Just print the exact message to show the event choreography result.