Cloudflare Docs
Queues
Visit Queues on GitHub
Set theme to dark (⇧+D)

Configuration

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 Worker has a wrangler.toml 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.toml file.

Use the options below to configure your Queue.

​​ Producer

To enable Producer Worker to Queue communication, set up a binding in your wrangler.toml file. These options should be used when a Worker wants to send messages to a Queue.

[[queues.producers]]
queue = "my-queue"
binding = "MY_QUEUE"
  • queuestring

    • The name of the Queue.
  • bindingstring

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

​​ Consumer

To enable Consumer Worker to Queue communication, set up a binding in your wrangler.toml 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"

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

  • queuestring

    • The name of the Queue.
  • max_batch_sizenumber optional

    • The maximum number of messages allowed in each batch.
  • max_batch_timeoutnumber optional

    • The maximum number of seconds to wait until a batch is full.
  • max_retriesnumber optional

    • The maximum number of retries for a message, if it fails or retryAll() is invoked.
  • dead_letter_queuestring 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.
  • max_concurrencynumber optional

    • The maximum number of concurrent consumers allowed to run at once. Leaving this unset, or setting it to null, will mean that the number of invocations will scale to the currently supported maximum.