This project is a sample implementation of the Saga Pattern using Choreography. It is a simple application that allows users to create a new order and pay for it. The application is implemented using Spring Boot and Spring Cloud Stream. The communication between the services is done using Apache Kafka.
- The Saga Pattern is a pattern for managing distributed transactions. It is a sequence of local transactions.
- Each local transaction updates the database and publishes a message or event to trigger the next local transaction in the saga.
- If a local transaction fails because it violates a business rule then the saga executes a series of "compensating transactions" that undo the changes that were made by the preceding local transactions.
- For example, you can take a look at the image below:
You need to have the following installed on your machine:
First start the Kafka cluster, Database and administation tools by running the following command:
docker-compose up -d
Then start each services by running the following command:
./mvnw spring-boot:run