Publish Order Events Reliably With the Transactional Outbox Pattern

Last updated: November 29, 2026

Quick Overview

After saving an order, the service publishes an OrderPlaced event, but crashes between the two steps produce orders with no event or events for orders that rolled back. Implement the transactional outbox so the event is committed with the order and relayed later at least once, with idempotent consumers.

Amazon
Software Engineering Fundamentals
Software Engineer
Amazon
November 29, 2026
Software Engineer
System Design Round
Software Engineering Fundamentals
Hard

0

0

0 solved


After saving an order, the service publishes an OrderPlaced event, but crashes between the two steps produce orders with no event or events for orders that rolled back. Implement the transactional outbox so the event is committed with the order and relayed later at least once, with idempotent consumers.

Amazon's order pipeline fans out to fulfillment, payments, and notifications through queues, so keeping the database and the event stream consistent without distributed transactions is essential. The interviewer checks the dual-write problem, ordering, at-least-once delivery, and deduplication on the consumer side.

What the Interviewer Expects
  • Explains the dual-write problem in both failure orders
  • Writes the business row and the outbox row in one local transaction
  • Relays in commit order and marks rows only after a successful publish
  • States that delivery is at least once and makes consumers idempotent by event id
  • Discusses change data capture as an alternative to polling
Key Topics to Cover
transactional outbox
dual writes
at-least-once delivery
idempotent consumers
event ordering
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
  • How would you run several relay workers without reordering events for the same order?
  • How would DynamoDB Streams or a CDC tool replace the polling relay?
  • How do you clean up published outbox rows?
  • What latency does polling add and how would you reduce it?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements
  • Never publish an event for an order that did not commit, and never lose an event for one that did.
  • Events for the store are published in commit order.
  • Consumers may see duplicates and must handl...
High-Level Design

place_order inserts the order and an outbox row in one transaction, so both or neither exist. A relay polls unpublished rows by sequence, publishes each, then marks it. If publish fails, it stops to...


Submit Your Answer
Markdown supported