Skip to content

Saga example using AMQP (rabbit) and nodejs to emulate bank transactions using the message broker

License

Notifications You must be signed in to change notification settings

joseteodoro/saga-example-with-amqp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple SAGA example using amqp and nodejs

The banks works as the following the diagram:

bank system diagram

All the banks are listening their own queue on the broker. Everytime some transactions comes, they try to resolve it. When the transaction fail, the bank sends a compensation rolling back the transaction to the sender bank.

How to use it

Before everything, start the rabbit:

./start-rabbit.sh

to create a bank

node src/create-bank.js <bank-name>

to create an account

node src/create-account.js <bank-name>

to transfer between accounts

node src/transfer.js <src-bank> <src-account> <target-bank> <target-account> <value>

You can start a batch listener using

node src/batch-bank.js <bank-name>

You can deposit using

node src/deposit.js <bank-name> <account> <value>

You can withdraw using

node src/withdraw.js <bank-name> <account> <value>

About

Saga example using AMQP (rabbit) and nodejs to emulate bank transactions using the message broker

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published