1.3.2 Saga Transaction Protocol

The following image describes how the microservices communicate with each other and with MicroTx when you use the Saga transaction protocol, which is based on Eclipse MicroProfile Long Running Actions (LRA).

Microservices using the LRA transaction protocol

Let's understand how the microservices communicate with each other to process a sample transaction.

  1. The transaction initiator service calls the MicroTx Saga coordinator and passes its callback URIs to begin and enlist in the Saga transaction.
  2. The transaction initiator service calls one or more participant services by passing the ID of the Saga in headers.
  3. The other participant services call MicroTx and enlist or join the Saga transaction. When participants join the Saga, they provide callback URIs including ones for completing and compensating their part of the Saga.
  4. The transaction initiator service calls MicroTx to either complete or compensate the transaction.
  5. MicroTx calls each participant service's complete callback URI or compensate callback URI depending upon whether the transaction initiator service asks to complete or compensate the transaction.

Each participant uses local transactions that are independent from each other. Since the Saga transaction protocol uses local transactions, there are periods when the overall state of the system is inconsistent while the goal of the transaction is to achieve consistency at the end of the transaction. This is because the local transactions complete or compensate independently. As a result, there are periods when one or more local transactions are completed or compensated while others have not. Because of the lack of locking and isolation, other systems or users will be able to see these inconsistent states and potentially make faulty decisions based upon those inconsistent states.