Saga Architecture Pattern
Instead of asking all the participants to commit and then rollback like Two Phase Commit, we follow a sequence flows. So we commit one by one and only rollback if one fails.
Similar to TCC - Try Confirm Cancel but however provide a way to rollback at each step
How it works
We can make a Service Wrapper for example and call rollback()
function in relevant service if one fails
Pros and cons
Pros
- Easy to implement
- Minimum locking
- Retry mechanism
Cons
- As our service grows, the wrapper can become complex