3-service microservices system implementing distributed SAGA orchestration using Kafka Streams.
# 1. Start Docker (Kafka + Zookeeper)
docker-compose up -d
# 2. Start all services
./start.sh
# 3. Create test order
curl -X POST http://localhost:8081/api/orders \
-H "Content-Type: application.json" \
-d '{
"customerId": "CUST-001",
"items": [
{"productId": "PROD-001", "productName": "Laptop", "quantity": 2, "price": 1000.00}
]
}'📖 ARCHITECTURE.md - Complete architecture, flow diagrams, and implementation details
📖 KAFKA-STREAMS-IMPLEMENTATION.md - Deep dive into Kafka Streams setup
- order-service (8081) - Order management + Kafka Streams orchestrator
- payment-service (8082) - Payment processing
- stock-service (8083) - Inventory management
- Kafka Streams - KStream-KStream joins with 10-second time windows
- SAGA Pattern - Distributed transaction coordination
- Event-Driven - Kafka topics for inter-service communication
- Exactly-Once Semantics - Reliable processing with RocksDB state store
User → Order Service → Kafka (order-created)
↓
┌────────────┴────────────┐
▼ ▼
Payment Service Stock Service
│ │
▼ ▼
Kafka (payment-events) Kafka (stock-events)
│ │
└────────┬────────────────┘
▼
⭐ KAFKA STREAMS JOIN ⭐
(OrderStreamProcessor)
│
▼
Kafka (order-events)
│
┌────────────┼────────────┐
▼ ▼ ▼
Order Svc Payment Svc Stock Svc
(Update) (Confirm/ (Confirm/
(Status) Rollback) Release)
Run all SAGA test scenarios:
./test-orders.shTests 5 scenarios: CONFIRMED, REJECTED, ROLLBACK (payment fails), ROLLBACK (stock fails), multi-item orders.
tail -f logs/order-service.log # Kafka Streams join logs
tail -f logs/payment-service.log
tail -f logs/stock-service.logBrowse topics and messages: http://localhost:8080