https://github.com/teamhide/python-saga-pattern-example
Python SAGA Pattern Example
https://github.com/teamhide/python-saga-pattern-example
Last synced: 11 months ago
JSON representation
Python SAGA Pattern Example
- Host: GitHub
- URL: https://github.com/teamhide/python-saga-pattern-example
- Owner: teamhide
- Created: 2020-04-13T10:36:57.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-04-25T06:01:59.000Z (about 2 years ago)
- Last Synced: 2025-05-06T18:47:33.859Z (about 1 year ago)
- Language: Python
- Size: 228 KB
- Stars: 55
- Watchers: 1
- Forks: 9
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Python SAGA Pattern Example
Implemented SAGA Pattern through python for distributed transaction.
- FastAPI
- RabbitMQ
There is three microsevices.
- Order
- Stock
- Delivery
**Case of success**

Each service is listening to a specific queue, as shown above.
To briefly explain the flow,
1. **User** - Order product through `/order/{item_id}`
2. **Order** - Execute local transaction
3. **Order** - Produce event to `ORDER_CREATED`
4. **Stock** - Consume `ORDER_CREATED` and if got some, execute local transaction
5. **Stock** - Produce event to `STOCK_SUCCESS`
6. **DELIVERY** - Consume `STOCK_SUCCESS` and if got some, execute local transaction
7. **DELIVERY** - Produce event to `DELIVERY_SUCCESS`
8. **Order** - Consume `DELIVERY_SUCCESS`
9. **Order** - Change order status to `complete` and distributed transaction is end