Skip to content

Commit 4cf0d7f

Browse files
authored
Added Queues message retention period documentation (#19981)
1 parent 5a61ffc commit 4cf0d7f

File tree

4 files changed

+74
-20
lines changed

4 files changed

+74
-20
lines changed
118 KB
Loading
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
title: Customize queue message retention periods
3+
description: Customize the retention period for a queue, from a minimum of 60 seconds to a maximum of 14 days.
4+
products:
5+
- queues
6+
date: 2025-02-14 12:00:00 UTC
7+
---
8+
9+
You can now customize a queue's message retention period, from a minimum of 60 seconds to a maximum of 14 days. Previously, it was fixed to the default of 4 days.
10+
11+
![Customize a queue's message retention period](~/assets/images/queues/customize-retention-period.png)
12+
13+
You can customize the retention period on the settings page for your queue, or using Wrangler:
14+
15+
```bash title="Update message retention period"
16+
$ wrangler queues update my-queue --message-retention-period-secs 600
17+
```
18+
19+
This feature is available on all new and existing queues. If you haven't used Cloudflare Queues before, [get started with the Cloudflare Queues guide](/queues/get-started).

src/content/docs/queues/configuration/configure-queues.mdx

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,41 @@ head:
99

1010
---
1111

12-
import { WranglerConfig } from "~/components";
12+
import { WranglerConfig, Type } from "~/components";
1313

1414
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.
1515

16-
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.
16+
17+
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.
1718

1819
Use the options below to configure your queue.
1920

2021
:::note
2122

2223

23-
Below are options for Queues, refer to the Wrangler documentation for a full reference of the [Wrangler configuration file](/workers/wrangler/configuration/).
24+
Below are options for queues, refer to the Wrangler documentation for a full reference of the [Wrangler configuration file](/workers/wrangler/configuration/).
2425

2526

2627
:::
2728

28-
## Producer
29+
## Queue configuration
30+
The following queue level settings can be configured using Wrangler:
31+
32+
```sh
33+
$ npx run wrangler queues update --delivery-delay-secs 60 --message-retention-period-secs 3000
34+
```
35+
36+
* `--delivery-delay-secs` <Type text="number" /> <Type text="optional" />
37+
* How long a published message is delayed for, before it is delivered to consumers.
38+
* Must be between 0 and 43200 (12 hours).
39+
* Defaults to 0.
40+
41+
* `--message-retention-period-secs` <Type text="number" /> <Type text="optional" />
42+
* How long messages are retained on the Queue.
43+
* Defaults to 345600 (4 days).
44+
* Must be between 60 and 1209600 (14 days)
45+
46+
## Producer Worker configuration
2947

3048
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.
3149

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

4462

4563

46-
* <code>queue</code> string
64+
* <code>queue</code> <Type text="string" />
4765

48-
* The name of the Queue.
66+
* The name of the queue.
4967

50-
* <code>binding</code> string
68+
* <code>binding</code> <Type text="string" />
5169

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

5472

5573

56-
## Consumer
57-
58-
## Workers
74+
## Consumer Worker Configuration
5975

6076
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.
6177

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

7995

8096

81-
* <code>queue</code> string
97+
* <code>queue</code> <Type text="string" />
8298

83-
* The name of the Queue.
99+
* The name of the queue.
84100

85-
* <code>max\_batch\_size</code> number optional
101+
* <code>max\_batch\_size</code> <Type text="number" /> <Type text="optional" />
86102

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

90-
* <code>max\_batch\_timeout</code> number optional
106+
* <code>max\_batch\_timeout</code> <Type text="number" /> <Type text="optional" />
91107

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

95-
* <code>max\_retries</code> number optional
111+
* <code>max\_retries</code> <Type text="number" /> <Type text="optional" />
96112

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

100-
* <code>dead\_letter\_queue</code> string optional
116+
* <code>dead\_letter\_queue</code> <Type text="string" /> <Type text="optional" />
101117

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

106-
* <code>max\_concurrency</code> number optional
122+
* <code>max\_concurrency</code> <Type text="number" /> <Type text="optional" />
107123

108124
* 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/).
109125
* Refer to [Consumer concurrency](/queues/configuration/consumer-concurrency/) for more information on how consumers autoscale, particularly when messages are retried.

src/content/docs/workers/wrangler/commands.mdx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1244,7 +1244,7 @@ Manage your Workers [Queues](/queues/) configurations.
12441244

12451245
### `create`
12461246

1247-
Create a new Queue.
1247+
Create a new queue.
12481248

12491249
```txt
12501250
wrangler queues create <name> [OPTIONS]
@@ -1254,6 +1254,25 @@ wrangler queues create <name> [OPTIONS]
12541254
- The name of the queue to create.
12551255
- `--delivery-delay-secs` <Type text="number" /> <MetaInfo text="optional" />
12561256
- How long a published message should be delayed for, in seconds. Must be a positive integer.
1257+
- `--message-retention-period-secs` <Type text="number" /> <MetaInfo text="optional" />
1258+
- How long a published message is retained in the Queue. Must be a positive integer between 60 and 1209600 (14 days). Defaults to 345600 (4 days).
1259+
1260+
<Render file="wrangler-commands/global-flags" product="workers" />
1261+
1262+
### `update`
1263+
1264+
Update an existing queue.
1265+
1266+
```txt
1267+
wrangler queues update <name> [OPTIONS]
1268+
```
1269+
1270+
- `name` <Type text="string" /> <MetaInfo text="required" />
1271+
- The name of the queue to update.
1272+
- `--delivery-delay-secs` <Type text="number" /> <MetaInfo text="optional" />
1273+
- How long a published message should be delayed for, in seconds. Must be a positive integer.
1274+
- `--message-retention-period-secs` <Type text="number" /> <MetaInfo text="optional" />
1275+
- 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).
12571276

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

0 commit comments

Comments
 (0)