Skip to main content

Outbox Pattern


What is it

A technique to update a resource while ensuring an event is published atomically.

It works by committing a data change simultaneously with inserting an event in an outbox table, both within the same transaction. Another part of the system is responsible for publishing these events, and remove them from the table after it has successfully published them.

Why we use it

To guarantee data correctness. If a resource is updated, an event is guaranteed to be published at-least-once eventually.

When to use it

When data correctness and at-least-once event publishing is required, for example to implement domain events to trigger side-effects, or change events for audit logging.

How to learn it