sylleryum / kafka-microservices-with-saga

Java (Spring) microservices example with Kafka and saga pattern
Apache License 2.0
55 stars 22 forks source link
kafka microservices spring-boot

codecov example workflow

Microservices with Kafka and Saga pattern using Spring boot

This project simulates a system for processing orders (i.e., a purchase) of items (E.g.: an order of a fridge and a camera) which is constituted of 4 microservices: order, stock, payment and notification service.

High level architecture:

Note: as the main objective of this project is to demonstrate Kafka, majority of microservice patterns are ignored as well as some best practices for simplicity/readability’s sake (E.g.: Transactional outbox and coding to the interface).

Getting started / Installation:

Option 1: Running locally

Option 2: Running on Docker

Instructions:

How it works:

Once a new order is received, the order service does the initial processing and sends a new event to kafka:

All microservices involved in the order will perform their corresponding operations and send a confirmation back to Kafka (success/failure):

Order service then uses Kafka Streams to join all the confirmations received (inner join). If all services returned a success event, order has been fully processed (order completed). If any service returns a failure message, order service then triggers an event of rollback which will be processed by all other services. Order service also sends the final order status to Kafka, notification service simulates then a notification message to user informing the final status of his/her order:

Configurations: