This repository demonstrates two microservices communication patterns using Spring Boot:
- 🎼 Orchestration Pattern — Centralized control using REST calls
- 💃 Choreography Pattern — Decentralized, event-driven using Apache Kafka
Feature | Technology |
---|---|
Language | Java 17 |
Framework | Spring Boot 3.x |
Messaging (Choreo) | Apache Kafka |
REST Clients | Spring Cloud OpenFeign |
Build Tool | Maven |
Architecture | Microservices |
In this approach, the order-service
controls the flow:
- Client →
order-service
order-service
→ callsinventory
,payment
, andshipping
via REST- Centralized decision-making and error handling
cd order-orchestration/
# Run each service individually:
cd order-service && mvn spring-boot:run
cd inventory-service && mvn spring-boot:run
cd payment-service && mvn spring-boot:run
cd shipping-service && mvn spring-boot:run
In this approach, services listen to events and react accordingly:
- order-service emits "order-created" event
- inventory-service listens → emits "inventory-checked"
- payment-service listens → emits "payment-completed"
- shipping-service listens and ships
# ▶️ Prerequisite: Kafka | manually run
docker run -d --name zookeeper -p 2181:2181 zookeeper
docker run -d --name kafka -p 9092:9092 --link zookeeper \
-e KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181 \
-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092 \
confluentinc/cp-kafka
# ▶️ Run Services
cd order-choreography/
cd order-service && mvn spring-boot:run
cd inventory-service && mvn spring-boot:run
cd payment-service && mvn spring-boot:run
cd shipping-service && mvn spring-boot:run