Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
48adb13
added queues retention period documentation
maheshwarip Feb 13, 2025
30c9ba6
Update src/content/docs/queues/configuration/configure-queues.mdx
maheshwarip Feb 13, 2025
a7b2c62
Update src/content/docs/queues/configuration/configure-queues.mdx
maheshwarip Feb 13, 2025
837e6fc
Update 2025-02-14-customize-queue-retention-period.mdx
maheshwarip Feb 13, 2025
da508e4
Update src/content/docs/queues/configuration/configure-queues.mdx
maheshwarip Feb 14, 2025
91c8e81
Update src/content/docs/workers/wrangler/commands.mdx
maheshwarip Feb 14, 2025
54153b6
Update src/content/docs/queues/configuration/configure-queues.mdx
maheshwarip Feb 14, 2025
f564f67
Update src/content/docs/workers/wrangler/commands.mdx
maheshwarip Feb 14, 2025
70b7920
Update src/content/changelog/queues/2025-02-14-customize-queue-retent…
maheshwarip Feb 14, 2025
f44bbb0
Update src/content/changelog/queues/2025-02-14-customize-queue-retent…
maheshwarip Feb 14, 2025
fbc5370
Update src/content/changelog/queues/2025-02-14-customize-queue-retent…
maheshwarip Feb 14, 2025
1c73803
Update src/content/changelog/queues/2025-02-14-customize-queue-retent…
maheshwarip Feb 14, 2025
16f7843
Update src/content/changelog/queues/2025-02-14-customize-queue-retent…
maheshwarip Feb 14, 2025
4b0ce9f
Update 2025-02-14-customize-queue-retention-period.mdx
maheshwarip Feb 14, 2025
56ba238
Update 2025-02-14-customize-queue-retention-period.mdx
maheshwarip Feb 14, 2025
b5bf465
Update 2025-02-14-customize-queue-retention-period.mdx
maheshwarip Feb 14, 2025
f6deb8a
Update 2025-02-14-customize-queue-retention-period.mdx
maheshwarip Feb 14, 2025
8220277
Update configure-queues.mdx
maheshwarip Feb 14, 2025
c5aa837
Update commands.mdx
maheshwarip Feb 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
title: Customize Queue message retention periods
description: Customize the retention period for a Queue, starting from 60 seconds to a maximum of 14 days.
products:
- queues
date: 2025-02-14 12:00:00 UTC
---

You can customize a Queue's message retention period, starting from 60s to a maximum of 14 days. Visit the [queues docs](/queues/configuration/configure-queues#queue-configuration) to learn more.

![Customize a Queue's message retention period](~/assets/images/queues/customize-retention-period.png)

By default, Queues retain messages for a default of 4 days. Previously, it was impossible to change the retention period.

With this update, you can retain messages for up to 14 days. Or if you want your consumer to only consume newer messages, you can set the message expiry period to be as short as 60 seconds.

You can customize the retention period on the Queues settings page on the dashboard, or using Wrangler:
```bash title="Update message retention period"
$ wrangler queues update my-queue --message-retention-period-secs 600
```

This feature is available on all new and existing Queues. If you haven't used Cloudflare Queues before, [get started with our guide here](/queues/get-started).
45 changes: 31 additions & 14 deletions src/content/docs/queues/configuration/configure-queues.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ head:

---

import { WranglerConfig } from "~/components";
import { WranglerConfig, Type } from "~/components";

Cloudflare Queues can be configured using [Wrangler](/workers/wrangler/install-and-update/), the command-line interface for Cloudflare's Developer Platform, which includes [Workers](/workers/), [R2](/r2/), and other developer products.

Each Worker has a [Wrangler configuration file](/workers/wrangler/configuration/) that specifies environment variables, triggers, and resources, such as a Queue. To enable Worker-to-resource communication, you must set up a [binding](/workers/runtime-apis/bindings/) in your Worker project's Wrangler file.
Cloudflare Queues can be configured using [Wrangler](/workers/wrangler/install-and-update/), the command-line interface for Cloudflare's Developer Platform, which includes [Workers](/workers/), [R2](/r2/), and other developer products.

Each Producer and Consumer Worker has a [Wrangler configuration file](/workers/wrangler/configuration/) that specifies environment variables, triggers, and resources, such as a Queue. To enable Worker-to-resource communication, you must set up a [binding](/workers/runtime-apis/bindings/) in your Worker project's Wrangler file.

Use the options below to configure your queue.

Expand All @@ -25,7 +27,24 @@ Below are options for Queues, refer to the Wrangler documentation for a full ref

:::

## Producer
## Queue configuration
The following Queue level settings can be configured using Wrangler:

```sh
$ npx run wrangler queues update --delivery-delay-secs 60 --message-retention-period-secs 3000
```

* `--delivery-delay-secs` <Type text="number" /> <Type text="optional" />
* How long a published message is delayed for, before it is delivered to consumers.
* Must be between 0 and 43200 (12 hrs).
* Defaults to 0.

* `--message-retention-period-secs` <Type text="number" /> <Type text="optional" />
* How long messages are retained on the Queue.
* Defaults to 345600 (4 days).
* Must be between 60 and 1209600 (14 days)

## Producer Worker configuration

A producer is a [Cloudflare Worker](/workers/) that writes to one or more queues. A producer can accept messages over HTTP, asynchronously write messages when handling requests, and/or write to a queue from within a [Durable Object](/durable-objects/). Any Worker can write to a queue.

Expand All @@ -43,19 +62,17 @@ To produce to a queue, set up a binding in your Wrangler file. These options sho



* <code>queue</code> string
* <code>queue</code> <Type text="string" />

* The name of the Queue.

* <code>binding</code> string
* <code>binding</code> <Type text="string" />

* The name of the binding, which is a JavaScript variable.



## Consumer

## Workers
## Consumer Worker Configuration

To consume messages from one or more queues, set up a binding in your Wrangler file. These options should be used when a Worker wants to receive messages from a queue.

Expand All @@ -78,32 +95,32 @@ Refer to [Limits](/queues/platform/limits) to review the maximum values for each



* <code>queue</code> string
* <code>queue</code> <Type text="string" />

* The name of the Queue.

* <code>max\_batch\_size</code> number optional
* <code>max\_batch\_size</code> <Type text="number" /> <Type text="optional" />

* The maximum number of messages allowed in each batch.
* Defaults to `10` messages.

* <code>max\_batch\_timeout</code> number optional
* <code>max\_batch\_timeout</code> <Type text="number" /> <Type text="optional" />

* The maximum number of seconds to wait until a batch is full.
* Defaults to `5` seconds.

* <code>max\_retries</code> number optional
* <code>max\_retries</code> <Type text="number" /> <Type text="optional" />

* The maximum number of retries for a message, if it fails or [`retryAll()`](/queues/configuration/javascript-apis/#messagebatch) is invoked.
* Defaults to `3` retries.

* <code>dead\_letter\_queue</code> string optional
* <code>dead\_letter\_queue</code> <Type text="string" /> <Type text="optional" />

* The name of another Queue to send a message if it fails processing at least `max_retries` times.
* If a `dead_letter_queue` is not defined, messages that repeatedly fail processing will eventually be discarded.
* If there is no Queue with the specified name, it will be created automatically.

* <code>max\_concurrency</code> number optional
* <code>max\_concurrency</code> <Type text="number" /> <Type text="optional" />

* The maximum number of concurrent consumers allowed to run at once. Leaving this unset will mean that the number of invocations will scale to the [currently supported maximum](/queues/platform/limits/).
* Refer to [Consumer concurrency](/queues/configuration/consumer-concurrency/) for more information on how consumers autoscale, particularly when messages are retried.
Expand Down
19 changes: 19 additions & 0 deletions src/content/docs/workers/wrangler/commands.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,25 @@ wrangler queues create <name> [OPTIONS]
- The name of the queue to create.
- `--delivery-delay-secs` <Type text="number" /> <MetaInfo text="optional" />
- How long a published message should be delayed for, in seconds. Must be a positive integer.
- `--message-retention-period-secs` <Type text="number" /> <MetaInfo text="optional" />
- How long a published message is retained on the Queue. Must be a positive integer between 60 and 1209600 (14 days). Defaults to 345600 (4 days).

<Render file="wrangler-commands/global-flags" product="workers" />

### `update`

Updae an existing Queue.

```txt
wrangler queues update <name> [OPTIONS]
```

- `name` <Type text="string" /> <MetaInfo text="required" />
- The name of the queue to update.
- `--delivery-delay-secs` <Type text="number" /> <MetaInfo text="optional" />
- How long a published message should be delayed for, in seconds. Must be a positive integer.
- `--message-retention-period-secs` <Type text="number" /> <MetaInfo text="optional" />
- How long a published message is retained on the Queue. Must be a positive integer between 60 and 1209600 (14 days). Defaults to 345600 (4 days).

<Render file="wrangler-commands/global-flags" product="workers" />

Expand Down
Loading