All projects

Backend & Microservices · 2026

Distributed Transactions with the Saga Pattern

A microservices project that keeps order and inventory services consistent using a choreography-based saga with Java 17, Spring Boot 3.3 and Apache Kafka.

What I did

  • The order service creates an order in PENDING state and publishes an event to Kafka.
  • The stock service checks inventory: if sufficient it decreases stock (COMPLETED), otherwise it rejects the transaction (CANCELLED).
  • Without a central orchestrator (choreography), the order is updated to its final state based on the stock service's reply.
  • Each service has its own isolated H2 database; the infrastructure runs with Docker Compose.

Tech stack

  • Java 17
  • Spring Boot 3.3
  • Apache Kafka
  • H2
  • Docker Compose

Related projects