A distributed command updates data in multiple services. Because services are separate process and transaction boundaries, coordinating the operation is harder than a local transaction. A common approach is to sequence local ACID transactions rather than use a distributed transaction. section 9.0 section 7.5.1
Eventual consistency trades strong, immediate consistency for availability:
- Services can respond while another service is unavailable. section 7.5.1
- The application must manage inconsistency, undo committed changes when needed, and handle concurrency; distributed queries cannot provide a strongly consistent cross-service view. section 7.5.1
- Saga and command-side replica are patterns for implementing distributed commands. section 7.5.1
Order creation and credit reservation
The Order Service can persist an order before the Consumer Service reserves the customer’s credit. If the Consumer Service is unavailable, the order request can still receive a response, but the operation requires careful coordination. section 7.5.1
Figure 7.9 Distributed transactions are replaced with a sequence of local transactions coordinated by asynchronous messaging
The figure illustrates replacing a distributed transaction with local transactions coordinated through asynchronous messaging. section 7.5.1
