INTEGRITY Cloudflare Docs

Configure Queues

Cloudflare Queues can be configured using Wrangler, the command-line interface for Cloudflare's Developer Platform, which includes Workers, R2, and other developer products.

Each Producer and Consumer Worker has a Wrangler configuration file that specifies environment variables, triggers, and resources, such as a queue. To enable Worker-to-resource communication, you must set up a binding in your Worker project's Wrangler file.

Use the options below to configure your queue.

Queue configuration

The following queue level settings can be configured using Wrangler:

npx wrangler queues update <QUEUE-NAME> --delivery-delay-secs 60 --message-retention-period-secs 3000

Producer Worker configuration

A producer is a Cloudflare Worker 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. Any Worker can write to a queue.

To produce to a queue, set up a binding in your Wrangler file. These options should be used when a Worker wants to send messages to a queue.

{
	"queues": {
		"producers": [
			{
				"queue": "my-queue",
				"binding": "MY_QUEUE"
			}
		]
	}
}
[[queues.producers]]
queue = "my-queue"
binding = "MY_QUEUE"

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.

{
	"queues": {
		"consumers": [
			{
				"queue": "my-queue",
				"max_batch_size": 10,
				"max_batch_timeout": 30,
				"max_retries": 10,
				"dead_letter_queue": "my-queue-dlq"
			}
		]
	}
}
[[queues.consumers]]
queue = "my-queue"
max_batch_size = 10
max_batch_timeout = 30
max_retries = 10
dead_letter_queue = "my-queue-dlq"

Refer to Limits to review the maximum values for each of these options.

Pull-based

A queue can have a HTTP-based consumer that pulls from the queue. This consumer can be any HTTP-speaking service that can communicate over the Internet. Review Pull consumers to learn how to configure a pull-based consumer.