In this video, we are going to learn the saga pattern for distributed transactions.
So the circle pattern is provided to manage data consistency across microservices in distributed transaction
cases.
Basically Saga Pattern offers to create a set of transactions that update microservices sequentially
and publish events to trigger the next transaction for the next microservices.
If one of two step is failed, then such a pattern trigger to roll back transactions, which is basically
the reverse operation with publishing rollback events to previous microservices.
By this way, it is managed distributed transactions across microservices as we know that it is used
some principles inside of the circle pattern like publish, subscribe, pattern with brokers or API
composition patterns.
So the circle pattern provide transaction management with using a sequence of local transactions of
microservices.
Even microservices has its own database and it can able to manage local transaction in atomic way with
strict consistency.
So such a pattern grouping these local transactions and sequentially in working one by one, each local
transaction updates the database and publishes an event to trigger the next local transaction.
If one of the step is failed, then suck up a time trigger to roll back transactions that are a set
of compensating transactions that roll back the change on previous microservices and restore data consistency.
So transaction management in is really hard when it comes to microservice architectures.
So in order to implementing transactions between several microservices and maintaining data consistency,
we should follow the circle pattern.
So Caperton has two different approaches.
The first one is choreography when exchanging events without points of control.
And the second way is orchestration when we have centralized controller.
So now let's explain these two ways of such a pattern in the next video.