Skip to content

Spring Boot microservices using orchestration and choreography patterns to demonstrate service communication and coordination approaches.

Notifications You must be signed in to change notification settings

meAltf/springboot-microservices-orchestration-vs-choreography

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🧩 Microservices with Orchestration & Choreography (Spring Boot)

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

🏗️ Project Structure

orchestration-project-structure

choreography-project-structure


🔧 Tech Stack

Feature Technology
Language Java 17
Framework Spring Boot 3.x
Messaging (Choreo) Apache Kafka
REST Clients Spring Cloud OpenFeign
Build Tool Maven
Architecture Microservices

🎼 Orchestration Pattern

In this approach, the order-service controls the flow:

  1. Client → order-service
  2. order-service → calls inventory, payment, and shipping via REST
  3. Centralized decision-making and error handling

▶️ Run Services

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

💃 Choreography Pattern

In this approach, services listen to events and react accordingly:

  1. order-service emits "order-created" event
  2. inventory-service listens → emits "inventory-checked"
  3. payment-service listens → emits "payment-completed"
  4. 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

🐳 docker-compose.yml for Choreography Project

Added in root of order-choreography/ project. as dockerfile.yml

About

Spring Boot microservices using orchestration and choreography patterns to demonstrate service communication and coordination approaches.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published