We have two separate services
Wallet and Discount
The Wallet Microservice is responsible for maintaining the user's financial information
and
Discount service The task of managing discount codes.
We want user be able to entering the code and charge his/her wallet.
I used Rest API to communicate at the same time and got help from message broker(RabbitMQ) where communication between microservices was needed.
But the way this connection was established had to be modeled on a distributed transaction Here I had two ways to do this process:
2pc or saga pattern
I preferred the saga method.
You can see my outline in the image below
Patterns for distributed transactions within a microservices architecture
git clone https://github.com/mohsen-farahani/microservice-challange.git
docker-compose up -d
- localhost:3000/campaigns/demand
- localhost:3000/wallets/{mobile}
- localhost:3000/users-campaigns
-
https://medium.com/hackernoon/-creating-simple-api-gateway-using-node-js-6d5933c214b8
-
https://designpatternsphp.readthedocs.io/en/latest/Behavioral/ChainOfResponsibilities/README.html
- unit test