Reliable Outbox Pattern Worker for Go.
Periodically fetches messages from your DB and reliably publishes them to AWS SNS or NATS JetStream.
In distributed systems, atomically updating the database and sending messages to a broker is challenging.
Outbox Messenger simplifies the **Outbox Pattern**, providing guaranteed ordering and high reliability.
Records with the same aggregate_id are sorted and published in order. Stops on failure to
preserve order.
Implements exponential backoff logic. Automatically retries during temporary failures while reducing load.
Supports AWS SNS and NATS JetStream. Automatically selects the publisher based on
aggregate_type (ARN/RN).
Click on the components below to explore the message flow.
Outbox Messenger mediates between your app and message brokers. It uses a polling model to avoid complex distributed transactions.
Click a component on the diagram to learn more.
Your application code.
Temporary storage for messages.
aggregate_type: Destination (ARN/RN)aggregate_id: Group ID for orderingpayload: JSON dataThe core component of this library.
aggregate_type, ordered by id.sent_at on success.The final destination of the messages.
topic.aggregate_id.Outbox Messenger comes with built-in logging and tracing capabilities ready for production.
Supported Handlers:
OpenTelemetry Support:
Configurable Service Name & Environment.
Your application must create a table with the following columns.
| Column | Type | Updater |
|---|---|---|
| aggregate_type | VARCHAR (ARN/RN) | App |
| aggregate_id | VARCHAR (Group ID) | App |
| payload | JSON | App |
| retry_at / sent_at | DATETIME | Worker |
The worker selects the backend publisher by parsing aggregate_type.
arn:aws:sns:region:account:topicrn::nats:::topic
On failure, the worker updates retry_at and retry_count using exponential
backoff.
Records with a future retry_at are skipped during fetching until that time is reached.