Saga rollback/compensating transaction example


Is there an example about how can we handle SAGA rollback/compensating transaction using Axon. I am tired of searching but didn’t get one.

Hi Manish,

A compensating action in Axon is also done with a command/event. If we take the example of a bank transfer and the amount is deducted from bank account A but cannot be added to bank account B a compensating command should be sent to bank account A to add the amount again.

I hope this answers your question


So does that mean, compensating actions should be manually implemented using command/events to revert each process that was executed on the way? Basically compensating transaction is nothing but the reverse execution of same steps using command/events?

Yes, for the processes that need a rollback that is correct. It is recommended to be explicit about that these are compensating actions and use different commands and events.