An outbox preserves notification intent; delivery deduplication is a separate boundary
Saving a record before calling a notification API leaves a gap where execution can stop. The data exists, but there is no record that a notification was required. Reversing the order can notify someone about data that never saved successfully. The outbox pattern saves business data and an event to deliver later in the same database transaction. That does not, by itself, make external delivery…
The outbox pattern stores business data and a message event to deliver later within the same database transaction. This ensures that if the transaction fails, the data remains intact but the notification intent is recorded. The pattern separates the creation of business records from the eventual delivery of notifications.
In an experiment conducted on September 11, 2026, the outbox insertion and note creation were placed in a single local database transaction. The consumer was tested to see if it could start delivering notifications independently from the business creation process. The experiment used a fake external service and no actual notifications were sent.
The outbox table stores the event ID, note ID, type, and payload. The event ID uniquely identifies the persisted event, while the payload contains the note ID and title. The database constraint ensures that only valid event types can be inserted.
After the business data and outbox entry were inserted, the consumer successfully transmitted the event to the fake provider. However, if the consumer stopped before updating the sent flag, the provider still processed the event, while the outbox still marked it as unsent. This showed that delivery can start separately from business creation.
However, without deduplication, the same event could be transmitted multiple times if the consumer stopped between transmission and recording. To prevent duplicate deliveries, the consumer could set a sent flag to 1 before transmission. But this approach would require a separate deduplication mechanism in the provider to handle failed sends.
A more robust solution would be for the consumer to recognize the event and consolidate retries based on the event ID. This ensures that each event is delivered only once, even in the presence of interruptions.
The experiment used a fake provider that treated the same event ID and payload as an existing result. When the consumer interrupted the delivery process and there was no deduplication, the provider received two calls but counted only one delivery. After implementing deduplication, the provider received the same interrupted calls but counted only one delivery.
The experiment demonstrated that an outbox alone does not guarantee exactly-once delivery. Additional measures, such as deduplication in the consumer or the provider, are necessary to handle duplicates and ensure reliable delivery. The outbox pattern provides a mechanism to ensure that business data and notification intent are stored atomically, but further steps are required to handle duplicates and integrate with real-world notification services.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.