skip to content

In Cloudflare Queues, what happens to a message that uses up its max_retries, with and without a dead_letter_queue configured?

level: middleimportance: should knowfreq 40%

answer

  1. retries end somewhere
  2. default three, limit 100
  3. unset means gone
  4. a DLQ needs its own consumer

basics

~20 s

Once a Queues message has used up max_retries (3 by default), it is deleted permanently unless the consumer sets dead_letter_queue, in which case it is written to that queue, which needs its own consumer to be processed.

solid answer

~40 s

Retry settings belong to the consumer: `max_retries` (default 3, platform limit 100), `retry_delay` for a default pause before redelivery, and `dead_letter_queue`. When a message fails its last allowed retry and no `dead_letter_queue` is set, it is **deleted permanently**. With one set, it is written to that queue instead. A dead-letter queue is an ordinary queue: nothing processes it until you give it a consumer, and per the docs messages on one with no active consumer persist for four days before deletion. Separately, any message that reaches the queue's retention period (default 4 days; up to 14 days on paid plans, capped at 24 hours on the Workers Free plan) is deleted.

code

json · 18 lines
json
{
  "name": "email-consumer",
  "main": "src/index.js",
  "compatibility_date": "2026-10-10",
  "queues": {
    "producers": [
      { "binding": "EMAILS_DLQ", "queue": "emails-dlq" }
    ],
    "consumers": [
      {
        "queue": "emails",
        "max_retries": 5,
        "retry_delay": 60,
        "dead_letter_queue": "emails-dlq"
      }
    ]
  }
}

go deeper

for a junior

Know the default of three retries and that, without a dead-letter queue, an exhausted message is deleted for good.

for a middle

Configure max_retries, retry_delay and dead_letter_queue in the consumer entry or with the matching wrangler queues consumer add flags, and explain why the dead-letter queue needs its own consumer.

for a senior

Account for the retention period as a second clock, long enough to hold your retry delays, and dead-letter messages that can never succeed instead of spending retries on them.

for a principal

Require a consumed, alerted dead-letter queue for any consumer whose messages carry business value, and keep one source of truth, file or CLI, for consumer settings.

In **Cloudflare Queues**, every message delivered to a consumer can fail: the handler throws, a promise rejects, or the code calls `message.retry()` or `batch.retryAll()`. Each failure sends the message round again. This question is about the end of that road: what the consumer's configuration says happens when the retries run out. ## The settings Retry behaviour belongs to the **consumer**, not the queue, and lives in the `queues.consumers` entry of the consuming Worker's Wrangler file (or on the consumer created with `wrangler queues consumer add`). | Setting | Meaning | Default and limits | |---|---|---| | `max_retries` | How many times a message may be retried after failing | 3; the platform limit is 100 | | `retry_delay` | Default seconds before a retried message is redelivered | Unset; a per-message `delaySeconds` overrides it | | `dead_letter_queue` | The queue that receives messages that exhausted their retries | Unset | The same settings exist as flags on `wrangler queues consumer add <queue-name> <script-name>`: `--message-retries`, `--retry-delay-secs` and `--dead-letter-queue`. If both the CLI and the Wrangler file change a consumer's settings, the most recent change takes effect, so pick one place as the source of truth. ## Without a dead-letter queue When a message reaches its retry limit and no `dead_letter_queue` is configured, it is **deleted permanently**; there is no copy to recover. For an email consumer, a message that fails four times in a row (the first delivery plus three retries at the default) is a welcome email that nobody will ever send. For a consumer whose messages matter, leaving `dead_letter_queue` unset is a decision to accept that loss. ## With a dead-letter queue When `dead_letter_queue` is set, the exhausted message is written to that queue instead. Three things follow: 1. **It is an ordinary queue.** A dead-letter queue can be produced to and consumed from like any other. That is why a consumer can also send a message there directly, through a producer binding, when it knows a message can never succeed, instead of spending its retries. 2. **Nothing reads it unless you configure a consumer.** Attaching a dead-letter queue to the main consumer does not process it. Give it its own consumer, a Worker or an HTTP pull consumer, that alerts, stores the message for inspection, or re-sends it to the main queue once the bug is fixed. 3. **An unread dead-letter queue still expires.** Per the dead-letter queue docs, messages on it with no active consumer persist for four days before they are deleted. A dead-letter queue nobody watches is a slower way of losing messages. A minimal configuration for the email consumer is in the code example: five retries, a one-minute default delay, and `emails-dlq` as the dead-letter queue, plus a producer binding so the consumer can park malformed messages there itself. ## Retention: the other way a message disappears Retries are not the only clock. Every queue has a **message retention period**: a message that reaches it is deleted from the queue. The default is four days (345,600 seconds). On paid plans it can be set from 60 seconds to 14 days, for example with `wrangler queues update emails --message-retention-period-secs 1209600`; on the Workers Free plan it is capped at 24 hours. Long retry delays and a growing backlog both push messages toward that limit, so a policy of "retry with long delays" needs a retention period long enough to hold it. ## Choosing the numbers - **Leave `max_retries` at 3 unless you have a reason.** The docs recommend the default for most consumers. Raise it when failures are mostly transient and slow to clear, and pair it with `retry_delay` so the attempts are spread over time instead of fired back to back. - **Remember that retries cost.** Each retry counts as an additional read operation for billing. - **Always set a dead-letter queue for messages you cannot afford to lose**, and give it a consumer. - **Dead-letter what cannot succeed straight away.** A message that fails validation will fail every attempt; sending it to the dead-letter queue at once saves the retries and the time. How a team triages and replays a dead-letter queue in general, and when dead-lettering is the wrong choice, is covered with dead-letter queues as a pattern. The Cloudflare-specific facts to carry are the default of three retries, permanent deletion without `dead_letter_queue`, and a dead-letter queue that does nothing until something consumes it.

  • How do you process the messages that land on a Queues dead-letter queue?
    Configure a consumer for the dead-letter queue itself, a Worker with a `queue()` handler or an HTTP pull consumer, exactly as for any queue. It can alert, store the message for inspection, or re-send it to the main queue through a producer binding once the cause is fixed.
  • Can a Queues message be deleted before it has used up its retries?
    Yes. A message that reaches the queue's message retention period is deleted from the queue regardless of retries. The default is four days, settable from 60 seconds to 14 days on paid plans with `wrangler queues update --message-retention-period-secs`, and capped at 24 hours on the Workers Free plan.

  • Without a dead_letter_queue, exhausted Queues messages wait on the queue for manual retry.
  • Setting dead_letter_queue makes the main consumer process the failed messages too.
  • max_retries is set on the queue itself when the queue is created.
  • Messages on an unconsumed dead-letter queue are kept indefinitely.
  • Raising max_retries to 100 is the safe default for any consumer.

As of 2026-10-10: message retention has been configurable from 60 seconds to 14 days since February 2025, and the Workers Free plan, which gained Queues in February 2026, caps it at 24 hours.