A transactional outbox is a table in a service’s own database into which the service writes each event in the same transaction as the change it announces; a separate relay reads the table, publishes the events in order, and marks them sent, so that an event is published if and only if its change was committed — at least once, with a key that lets the log or the consumer drop the repeats.
| design | events lost | phantom events | duplicated events |
|---|---|---|---|
| write the trade, then publish | 22 | 0 | 0 |
| publish, then write the trade | 0 | 22 | 0 |
| outbox, relay without idempotence key | 0 | 0 | 22 |
| outbox, relay with idempotence key | 0 | 0 | 0 |