> [!abstract] A pattern ensuring events are published even when the message bus is offline, by writing events to a database table within the same transaction as the data change. ## How It Works 1. Write data to your primary database table 2. Write the event to an "outbox" table 3. Wrap both writes in a **single transaction** - if either fails, neither happens 4. A separate service polls the outbox table for unpublished events 5. Publish events and mark them as published ## Benefits - Events are guaranteed to be published eventually - No data inconsistency between database and event bus - Can monitor outbox size for problems ## Sources [[x_Sources/Videos/Video - Build An Event Driven System - NDC Oslo 2024|Build An Event Driven System - James Eastham (NDC Oslo 2024)]]