1
00:00:00,210 --> 00:00:06,630
In this video, we are going to learn the saga pattern for distributed transactions.

2
00:00:06,840 --> 00:00:12,960
So the circle pattern is provided to manage data consistency across microservices in distributed transaction

3
00:00:12,960 --> 00:00:13,650
cases.

4
00:00:13,920 --> 00:00:20,490
Basically Saga Pattern offers to create a set of transactions that update microservices sequentially

5
00:00:20,490 --> 00:00:25,170
and publish events to trigger the next transaction for the next microservices.

6
00:00:25,950 --> 00:00:31,650
If one of two step is failed, then such a pattern trigger to roll back transactions, which is basically

7
00:00:31,650 --> 00:00:36,090
the reverse operation with publishing rollback events to previous microservices.

8
00:00:36,660 --> 00:00:42,960
By this way, it is managed distributed transactions across microservices as we know that it is used

9
00:00:42,960 --> 00:00:48,930
some principles inside of the circle pattern like publish, subscribe, pattern with brokers or API

10
00:00:48,960 --> 00:00:50,310
composition patterns.

11
00:00:52,030 --> 00:00:57,490
So the circle pattern provide transaction management with using a sequence of local transactions of

12
00:00:57,490 --> 00:00:58,540
microservices.

13
00:00:58,630 --> 00:01:05,410
Even microservices has its own database and it can able to manage local transaction in atomic way with

14
00:01:05,410 --> 00:01:06,850
strict consistency.

15
00:01:07,150 --> 00:01:13,390
So such a pattern grouping these local transactions and sequentially in working one by one, each local

16
00:01:13,390 --> 00:01:19,180
transaction updates the database and publishes an event to trigger the next local transaction.

17
00:01:19,510 --> 00:01:24,790
If one of the step is failed, then suck up a time trigger to roll back transactions that are a set

18
00:01:24,790 --> 00:01:31,840
of compensating transactions that roll back the change on previous microservices and restore data consistency.

19
00:01:33,440 --> 00:01:39,070
So transaction management in is really hard when it comes to microservice architectures.

20
00:01:39,080 --> 00:01:45,230
So in order to implementing transactions between several microservices and maintaining data consistency,

21
00:01:45,230 --> 00:01:47,120
we should follow the circle pattern.

22
00:01:47,120 --> 00:01:49,880
So Caperton has two different approaches.

23
00:01:50,060 --> 00:01:55,640
The first one is choreography when exchanging events without points of control.

24
00:01:55,730 --> 00:02:00,850
And the second way is orchestration when we have centralized controller.

25
00:02:01,010 --> 00:02:05,330
So now let's explain these two ways of such a pattern in the next video.
