1.1 How MicroTx Distributed Transactions Works
To use MicroTx Distributed Transactions, install MicroTx Distributed Transactions and then integrate the MicroTx Distributed Transactions client libraries with your application code to manage transactions.
About interceptors provided by the MicroTx Distributed Transactions client libraries
The MicroTx Distributed Transactions client libraries provide interceptors to intercept both incoming and outgoing REST calls, as well as their requests and responses. These interceptors use headers to propagate the transaction context which enable the participant microservices to automatically enlist in a transaction. The interceptors also ensure that the appropriate transaction headers are propagated in any outgoing REST call.
The following image shows the typical flow of request and responses and the role of the interceptor provided by the MicroTx Distributed Transactions libraries.

When a microservice, that uses the MicroTx Distributed Transactions client libraries, makes an outbound REST request, the library's interceptors add transaction headers to the outbound request if the microservice has started a distributed transaction or is currently participating in a distributed transaction. When a microservice receives a request, the interceptors in the recipient service identify the transaction headers and automatically enlist as a participant in the distributed transaction.
Here's a typical transaction workflow when you use MicroTx Distributed Transactions. The following figure shows how MicroTx Distributed Transactions communicates with your application microservices to handle transactions.

- Application developers use functions present in the MicroTx Distributed Transactions library with their application code.
- When a microservice or client initiates a transaction, it calls functions in the MicroTx Distributed Transactions library to start a distributed transaction.
- MicroTx Distributed Transactions library includes headers that enable the participant services to automatically enlist in the transaction.
- After all the tasks associated with the original request made by the initiator service are complete, the initiator service requests the transaction coordinator to either commit or roll back all the changes.
- The transaction coordinator sends a call to each participant service to either commit or roll back the changes made by the participants as part of the distributed transaction.
Parent topic: About MicroTx Distributed Transactions