Employing the Saga pattern
In Chapter 4, Trusting Facts and Eventual Consistency, we addressed the reality that modern distributed systems no longer rely on distributed transactions because they do not scale well and because of the heterogeneity of the many technologies involved. Instead, we create resilient, eventually consistent systems by breaking long-lived transactions down into a sequence of atomic actions. The outcome of each action is emitted as an event that is recorded as a fact. Downstream services react and the cycle repeats until the system reaches a consistent state in near-real time.However, we do need to account for scenarios when something goes wrong downstream and the long-lived transaction is not able to move forward to a consistent state. In these cases, we need to undo the sequence of actions performed up to the point of failure so that the system is returned to a consistent state. This pattern is referred to as a Saga and was first discussed by Hector Garcia-Molina...