Objective is to ensure data consistency across microservices that own the data and database platform.
Allows execution of distributed business transactions, executing a set of operations across multiple microservices , applying all or nothing semantics
Distributed transactions = Using Local Transactions coupled with compensating transactions
Think of SAGA like a Pipeline where each step is executed independent of the other step but in a sequence defined in/by the pipeline This continues till ALL steps have succeeded or one of the steps fails
This illustration shows the SAGA implentation for an eCommerce system that uses EDA. Each microservice implements the:
Eventual consistency
No Isolation = Intermediate state is visible. SAGA provides isolation level = READ Uncommitted
Transaction & Compensations must be idempotent
Commutative transactions
Transactions & Compensation MUST not be impacted by duplicate events