liveBook · Manning

XA

As explained in Microservices Patterns, Second Edition

A standard distributed transaction processing model that defines coordination among transaction participants through a global transaction manager.

XA is the X/Open Distributed Transaction Processing model for coordinating distributed ACID transactions across services, databases, or message brokers. It requires XA-compliant participants, drivers and APIs, and a way to propagate a global transaction identifier. A transaction coordinator uses two-phase commit: participants vote during preparation, then commit or roll back according to the collected votes. section 9.1.2

A cross-service order

A createOrder command spanning the Order Service and Customer Service would require both services and their databases to participate in the same transaction. section 9.1.2

Figure 9.1 A hypothetical implementation of XA/2PC in a microservice architecture. The services register as participants with the Transaction Coordinator. They enlist their databases in the distributed transaction. The Transaction Coordinator commits the transaction in two phases. In the prepare phases, participants vote on whether they can commit. In the commit phase, the transaction coordinator instructs all participants to either commit or roll back based on the collected votes.
microservices 2pc

Shows services enlisting databases with a transaction coordinator, which collects prepare votes before directing commit or rollback. section 9.1.2

Distributed ACID transactions are problematic in microservice architectures and should not be used there. Understanding XA clarifies the motivation and trade-offs behind the Saga pattern. section 9.1.2

How Microservices Patterns, Second Edition covers it

How deep it goes
Defines XA participant requirements and explains coordinator-led two-phase commit, including prepare votes and commit or rollback.
Examples
Uses a createOrder command spanning the Order Service and Customer Service, plus a coordinator-and-participant architecture.
What you can do after
Evaluate distributed transactions against sagas by understanding XA's coordination model and its problematic fit for microservices.
How it connects
Connects distributed ACID transactions and two-phase commit to microservices and the Saga pattern.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Microservices Patterns, Second Edition. The section links point to the parts of the book it draws on.