Skip to content

Latest commit

 

History

History
48 lines (33 loc) · 1018 Bytes

readme.md

File metadata and controls

48 lines (33 loc) · 1018 Bytes

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>