Skip to content

Commit 48adb13

Browse files
committed
added queues retention period documentation
1 parent 91ecba3 commit 48adb13

File tree

4 files changed

+72
-14
lines changed

4 files changed

+72
-14
lines changed
118 KB
Loading
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
title: Customize Queue message retention periods
3+
description: Customize the retention period for a queue, starting from 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 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.
10+
11+
![Customize a Queue's message retention period](~/assets/images/queues/customize-retention-period.png)
12+
13+
By default, Queues retain messages for a default of 4 days. Previously, it was impossible to change the retention period.
14+
15+
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.
16+
17+
You can customize the retention period on the Queues settings page on the dashboard, or using Wrangler:
18+
```bash title="Update message retention period"
19+
$ wrangler queues update my-queue --message-retention-period-secs 600
20+
```
21+
22+
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).

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

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ 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+
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.
17+
18+
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.
1719

1820
Use the options below to configure your queue.
1921

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

2628
:::
2729

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

3049
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.
3150

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

4463

4564

46-
* <code>queue</code> string
65+
* <code>queue</code> <Type text="string" />
4766

4867
* The name of the Queue.
4968

50-
* <code>binding</code> string
69+
* <code>binding</code> <Type text="string" />
5170

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

5473

5574

56-
## Consumer
57-
58-
## Workers
75+
## Consumer worker configuration
5976

6077
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.
6178

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

7996

8097

81-
* <code>queue</code> string
98+
* <code>queue</code> <Type text="string" />
8299

83100
* The name of the Queue.
84101

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

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

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

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

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

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

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

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

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

108125
* 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/).
109126
* 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: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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 on 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+
Updae 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)