−50%

50% off your first month on any paid plan · code WELCOME50 · until Nov 30

Start free →
Glossary · D

What is a dead-letter queue? Failed message handling

Definitiondead-letter queue · noun

A dead-letter queue (DLQ) is a holding area for messages that a system cannot process or deliver.

Messages fail for predictable reasons: wrong format, unreachable endpoint, expired TTL. Instead of discarding them or retrying forever, the system moves them to the DLQ. The failed message sits there until someone investigates.

The term originates from postal services. A "dead letter" was mail that couldn't be delivered or returned to the sender. Message brokers and cloud platforms adopted the concept: RabbitMQ, AWS SQS, Google Cloud Pub/Sub, and Azure Service Bus all support dead-letter queues natively.

Why dead-letter queues matter for scheduled tasks#

Scheduled jobs often trigger downstream work through queues or webhooks. A nightly report job might push results to an SQS queue for processing. A Cloud Cron task might call an API endpoint that feeds into a message pipeline. When something in that pipeline breaks, messages pile up or vanish. A DLQ catches what would otherwise be lost.

Without a DLQ, failed messages either retry indefinitely (wasting compute and potentially causing duplicate side effects) or get dropped silently. Both are bad for cron jobs that run unattended. You won't know the job's output never arrived until something downstream breaks hours or days later.

How a dead-letter queue works#

The basic flow: a producer sends a message to a queue. A consumer picks it up and tries to process it. If processing fails, the message goes back to the queue for a retry. After a configured number of retries (the "max receive count" in AWS terms), the system stops retrying and routes the message to the DLQ. The original queue moves on. Failures land in the DLQ for manual review or automated reprocessing.

How to monitor a dead-letter queue#

A DLQ without alerting is just a graveyard. Messages accumulate, nobody checks, failures go unnoticed. That matters. DLQ depth is one of the first metrics teams wire up to their alerting systems — if the count grows beyond a threshold, something upstream is broken.

For teams running scheduled tasks, combining a DLQ with cron job monitoring covers both sides of the problem. The monitor catches jobs that don't run. The DLQ catches jobs that run but produce output that can't be delivered. Together, they close the gap between "the job executed" and "the results actually arrived."

Frequently asked

Common causes include malformed message payloads, consumer bugs that throw exceptions on specific input, expired message TTLs, unreachable downstream services, and permission errors. The message itself isn't necessarily bad — the consumer might be misconfigured or temporarily broken.

Yes. Most queue systems let you move messages from the DLQ back to the original queue for reprocessing. AWS calls this 'DLQ redrive.' You fix the underlying issue first, then replay. Some teams automate this with a Lambda or worker that periodically retries DLQ messages.

Retries happen immediately or with backoff delays, keeping the message in the main queue. A DLQ is what happens after retries are exhausted. It's the last stop. Retries are optimistic (maybe the next attempt will work). A DLQ is pessimistic (this message needs human attention).

Yes. RabbitMQ, Apache Kafka (via error topics), and Redis-based queues like BullMQ all support dead-letter patterns. Email systems have used dead-letter handling since before cloud computing existed. The concept is universal to any system that delivers messages asynchronously.

Start monitoring in under 2 minutes.

Free plan includes 20 checks · No credit card required
Pricing Docs
Log in Start free →