liveBook · Manning

Requirements-driven transaction boundaries

As explained in Microservices Patterns, Second Edition

Requirements-driven transaction boundaries define transaction scope according to the specific consistency, performance, and integration requirements of each operation.

Requirements-driven transaction boundaries set transaction scope according to an operation’s requirements rather than organizing transactions uniformly around each operation or domain module. Choose the collaboration and transaction strategies together: synchronous invocation and observation fit a single transaction, while asynchronous messaging splits an operation into multiple transactions. section 6.2.4

For a cross-domain operation, compare the operational needs and consequences of each approach:

  • A single ACID transaction is the simplest option in a monolith, but it may not fit an operation whose collaboration divides work across transactions. section 6.2.4
  • A Saga coordinates multiple ACID transactions. If a later step can fail after earlier updates, those updates may require compensating transactions. section 6.2.4
  • Compensation is not always needed: if business rule violations can occur only within an earlier transaction, a later transaction may need none. section 6.2.4

Creating an order

The operation may create an order, reserve credit, and send a confirmation across Order, Consumer, and Notification Management. A Saga can separate these steps into transactions; if credit reservation fails after order updates, the Order module compensates for its changes. section 6.2.4

Figure 6.20 The createOrder() operation is implemented as a Saga, which consists of a sequence of ACID transactions in each of the three subdomains. Because reserving credit can fail, the Order Domain Module must use a compensating transaction to undo any updates that it did before invoking the Consumer Domain Module.
Transactional Commands transaction per domain simple

Shows a createOrder Saga and the compensating transaction used when credit reservation fails. section 6.2.4

How Microservices Patterns, Second Edition covers it

How deep it goes
Compares transaction strategies and illustrates Saga compensation, but does not specify a full decision procedure.
Examples
Uses createOrder across Order, Consumer, and Notification Management to contrast single and multiple transactions.
What you can do after
Evaluate transaction scope alongside collaboration choices and identify when a Saga may need compensation.
How it connects
Ties transaction scope to asynchronous messaging, transaction-per-operation, transaction-per-domain-module, and Saga.

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.