1.3.1 XA Transaction Protocol

An application using XA, must demarcate the transactions boundaries. MicroTx commits or rolls back the transaction.

In the XA protocol, participant microservices must use the MicroTx client libraries which registers callbacks and provides implementation of the callbacks for the resource manager. As shown in the following image, MicroTx communicates with the resource managers to commit or roll back the transaction. MicroTx connects with each resource manager involved in the transaction to prepare, commit, or rollback the transaction. The participant service provides the credentials to the coordinator to access the resource manager. As shown in the following figure, MicroTx client libraries provide a resource manager proxy (RM proxy). The proxy eliminates the need for the coordinator to have resource manager specific libraries, which would be the normal case in XA. When the transaction coordinator needs to prepare, commit, or rollback the transaction for a participant's resource manager, it makes a callback to the microservice and the proxy relays the request to the resource manager being used by the microservice. These REST-based callbacks allow the transaction coordinator to be agnostic to the resource manager used by the microservice.

Role of client libraries and RM proxy
  1. Initiator starts the distributed transaction
  2. Called microservices enlist in the transaction
  3. Initiator asks transaction manager to commit or rollback the transaction
  4. If the initiator decided to commit, the transaction manager asks each microservice to prepare
    1. If all participants successfully prepare, they are all asked to commit
    2. If any of the participants fail to prepare, they are all asked to rollback
  5. If the initiator decided to rollback the transaction, the transaction manager asks each microservice to rollback
To understand how the communication takes place between the microservices, MicroTx client libraries,and the coordinator, see About XA Sample Application.