Dead Letter Queue (DLQ)
Problem
Message-driven systems will fail — a poison message, an unexpected schema, a downstream outage that outlasts the retry policy. Without a dedicated failure surface, three bad things happen:
- Retry loops flood the log and consume RU / RPS budget.
- Whole subscriptions halt because a single bad message at the head can’t be processed.
- Silent data loss if messages are dropped after N retries.
A DLQ makes failure a first-class artifact — inspectable, replayable, alertable — instead of an invisible loss.
Solution
Use Azure Service Bus DLQ semantics — a per-subscription dead-letter sub-queue that receives messages after N failed deliveries or an explicit dead-letter operation.
Setup:
MaxDeliveryCounton the subscription (typically 5–10).- Retry policy with exponential backoff + jitter in the consumer.
- On terminal failure, message auto-dead-letters with reason
metadata (
DeadLetterReason,DeadLetterErrorDescription).
Operational discipline:
- DLQ dashboards — depth per subscription, growth rate.
- Alerts on DLQ growth (rate exceeds a threshold, or any message older than N minutes).
- Runbooks per subscription — how to inspect, root-cause, and replay or discard.
- Replay tooling — a curated way to move a message from DLQ back to the main subscription after a fix.
Explicit dead-letter reasons:
- Poison payload (schema violation).
- Unrecoverable business error (audit-relevant).
- Retry budget exhausted (transient failure outlasted policy).
When to use
- Every Service Bus subscription in ION — no exceptions on Beta / Prod.
- Any message-driven consumer where losing a message would be incorrect.
Not for:
- Fire-and-forget non-durable channels (rare in ION).
Consequences
Positive
- Failure is inspectable, not silent.
- Poison messages don’t halt the whole subscription.
- Recovery has a defined path (inspect → fix → replay).
- Aligns cleanly with idempotent consumers — replays are safe.
Negative
- Requires operational discipline — a DLQ nobody watches is worse than no DLQ.
- Replay tooling must exist and be trusted.
- DLQ storage counts toward Service Bus quotas.
Failure modes
- Unwatched DLQ — messages accumulate, incidents discovered late.
- Blind replay — replay before root-cause reintroduces the poison.
- MaxDeliveryCount too low — transient failures dead-letter needlessly.
- MaxDeliveryCount too high — real failures loop forever before hitting DLQ.
References
references/Design Pattern- Dead Letter Queue (DLQ).md- ADRs: 0008.
- Microsoft — Service Bus DLQ.
- Related patterns: Idempotent Write, Service Bus Topic Throttling.
Applied in
- Every ION Service Bus subscription — platform SDK enforces DLQ handler + reason metadata
- Ticket → ServiceNow outbound sync (
ticket.sync.failed@v1emitted alongside DLQ) - Pigeon notification delivery failures
- Watchtower Sentinel ingestion pipeline
- Cogs Temporal activity outbound events