Implemented SAGA Pattern through python for distributed transaction.
- FastAPI
- RabbitMQ
There is three microsevices.
- Order
- Stock
- Delivery
Each service is listening to a specific queue, as shown above.
To briefly explain the flow,
- User - Order product through
/order/{item_id}
- Order - Execute local transaction
- Order - Produce event to
ORDER_CREATED
- Stock - Consume
ORDER_CREATED
and if got some, execute local transaction - Stock - Produce event to
STOCK_SUCCESS
- DELIVERY - Consume
STOCK_SUCCESS
and if got some, execute local transaction - DELIVERY - Produce event to
DELIVERY_SUCCESS
- Order - Consume
DELIVERY_SUCCESS
- Order - Change order status to
complete
and distributed transaction is end