Order the steps
Order the steps of a 'place order' operation so no side effect escapes a rolled-back transaction.
- Validate the request (no transaction yet)
- COMMIT
- Consumer sends the confirmation email
- BEGIN; insert order and order lines; insert an outbox row
- Relay publishes the outbox row to the broker
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A D B E C
- Validate the request (no transaction yet) Cheap checks before taking any locks.
- BEGIN; insert order and order lines; insert an outbox row All database writes, one atomic unit.
- COMMIT Only now is the order real.
- Relay publishes the outbox row to the broker Happens after commit, so no ghost events.
- Consumer sends the confirmation email Email follows the event, never runs inside the transaction.