How do you avoid losing an email event after a booking commits?
After this you can answer: How do you avoid losing an email event after a booking commits?
Say it in 30 seconds
Section titled “Say it in 30 seconds”The deeper answer
Section titled “The deeper answer”Calling SNS only after committing a booking leaves a gap: the API can crash before publishing. Publishing first is worse because a worker could act on a booking that later rolls back. The outbox makes the intent to publish part of the same durable database decision.
The relay selects up to ten due rows under row locks, skipping rows another relay already holds. It publishes and marks accepted rows sent inside that transaction. Failures store a future due time with exponential backoff capped at sixty seconds. A missing topic configuration pauses delivery; it does not discard the outbox rows.
Holding a database connection during network publishing bounds overlap between relay tasks but extends transaction time. SDK timeouts and a single relay loop per process help limit the cost. For larger scale, I would measure backlog age and database occupancy before considering a different relay or change-data-capture design.
Counter-questions
Section titled “Counter-questions”What does a successful SNS response prove?
Can a crash still create a duplicate?
Why save event details rather than just an ID?
Where in MiniTickets
Section titled “Where in MiniTickets”Read Outbox, then inspect the outbox piece →.
apps/api/src/services/outbox.ts → relayOnceRead this book online: https://book.theversehub.in/