Storefront has been decoupled into micro-frontends with a dedicated commerce app and shared shell.

Read the architecture guide →

ADR-002: Use a durable outbox with bounded provider retries

Notification delivery attempts are driven by durable outbox records and a bounded retry policy so provider outages do not lose work or create unbounded duplicate sends.

October 27, 2026AcceptedReliability

1. Context & Problem

External email providers such as SendGridSystemv1.0.0SendGridExternal email delivery platform used by BookWorm to submit rendered transactional emails over authenticated SMTP. Ownerplatform-engineering-teamDiagramOpen docs can experience temporary outages, reject malformed requests, or enforce rate limits after BookWorm has already decided to notify a customer.

If BookWorm attempted to send emails directly inside a business transaction, a provider outage would cause lost notifications or fail the customer’s primary action. Conversely, retrying every failed delivery forever would flood the provider during an incident, generate duplicate emails, and mask permanent configuration or data errors. The architecture must separate durable internal acceptance of a notification from external delivery attempts, while remaining honest that no distributed integration can guarantee strictly single delivery without trade-offs.

2. Business Value

  • Zero silent loss during provider outages: Customer notifications remain safely queued inside BookWorm even when the external email service is unreachable.
  • Controlled recovery and cost protection: Bounded retries smooth over temporary network blips and rate limits without creating runaway retry storms.
  • Faster issue diagnosis: Distinguishing temporary delivery delays from permanent failures gives operations teams clear visibility into stuck queues, retry volume, and configuration errors.
  • Realistic operational expectations: Acknowledging the narrow window where duplicate sends can occur prepares support teams and downstream processes to handle ambiguity safely.

3. How It Works

The Notification SystemSystemv1.0.0Notification SystemInternal platform system that consumes order commands, renders email templates, and submits messages over SMTP. Ownerplatform-engineering-teamDiagramOpen docs uses a durable outbox paired with a bounded retry policy:

  1. Durable staging: Before contacting the external provider, the Notification SystemSystemv1.0.0Notification SystemInternal platform system that consumes order commands, renders email templates, and submits messages over SMTP. Ownerplatform-engineering-teamDiagramOpen docs saves each notification as a durable outbox record.
  2. Background dispatch: A background delivery worker picks up eligible items, submits them through SendGrid APIServicev1.0.0SendGrid APIExternal SMTP email delivery provider used by BookWorm to submit rendered order notification emails over authenticated S...Ownerplatform-engineering-teamDiagramOpen docs, and records the provider’s response.
  3. Bounded retry for temporary issues: When the provider is temporarily unavailable or throttles traffic, the item is retried on a bounded, observable schedule.
  4. Terminal failure for permanent issues: Invalid requests or permanent rejections are marked as terminal failures and stopped rather than retried indefinitely.
  5. Single advancement on success: When the provider confirms receipt, the outbox item is marked complete from BookWorm’s perspective, carrying a stable identifier across attempts so operators can trace retries and spot potential duplicates.

Because BookWorm’s internal storage and the external email service cannot confirm work in a single shared transaction, a response lost right after the provider accepts a message can make an item eligible for another attempt. Stable identifiers and recorded outcomes make that risk observable rather than hiding it.

4. Trade-offs & Lessons Learned

  • Eventual consistency and operational dependencies: Notification delivery is asynchronous, meaning teams must monitor queue age, retry counts, and terminal failures, and operate the notification store and worker reliably.
  • Ambiguous-outcome window: Even with durable local tracking, a failure between external acceptance and local confirmation can still cause a duplicate email; support workflows must account for that possibility.
  • Policy requires persisted state: Limiting batch sizes or short-term sender retries alone does not establish a true lifetime limit—bounded retries require stored attempt counts and an explicit terminal-failure state.
  • Target design vs. current gap: An accepted architecture decision sets the target contract, not automatic proof that current code satisfies every guarantee. Until attempt tracking, failure classification, and recovery tests are fully implemented, operations teams must not assume those safeguards are active.
  • Alternatives rejected:
    • Sending without an outbox: Risks losing notifications whenever the provider or network fails.
    • Retrying indefinitely: Amplifies outages and conceals permanent errors.
    • Claiming exactly-once delivery: Physically impossible across independent systems without an atomic distributed transaction.

5. Technical Reference

Target Outbox & Retry Contract

  • Components: Notification SystemSystemv1.0.0Notification SystemInternal platform system that consumes order commands, renders email templates, and submits messages over SMTP. Ownerplatform-engineering-teamDiagramOpen docs, outbox, SendGrid APIServicev1.0.0SendGrid APIExternal SMTP email delivery provider used by BookWorm to submit rendered order notification emails over authenticated S...Ownerplatform-engineering-teamDiagramOpen docs, SendGridSystemv1.0.0SendGridExternal email delivery platform used by BookWorm to submit rendered transactional emails over authenticated SMTP. Ownerplatform-engineering-teamDiagramOpen docs.
  • Storage boundary: PostgreSQL (local outbox persistence) and the external email provider do not share an atomic transaction; durable local state does not eliminate the ambiguous-outcome window between external submission and recording the provider result.
  • Required controls before relying on guarantees: Persisted attempt count, explicit terminal-failure classification, stable notification correlation identifiers, and automated recovery testing covering duplicates, timeouts, rate limits, and provider outages.

Implementation Alignment Gap

The current Notification implementation does not yet fully realize this ADR’s bounded-lifetime retry and terminal-failure behavior: