### Start Development Server Source: https://developers.cloudflare.com/queues/tutorials/handle-rate-limits Run this command to start the local development server for your Cloudflare Worker. ```bash npm run dev ``` -------------------------------- ### Install Resend Package (bun) Source: https://developers.cloudflare.com/queues/tutorials/handle-rate-limits Install the Resend package using bun to enable email sending functionality. ```bash bun add resend ``` -------------------------------- ### Install Resend Package (yarn) Source: https://developers.cloudflare.com/queues/tutorials/handle-rate-limits Install the Resend package using yarn to enable email sending functionality. ```bash yarn add resend ``` -------------------------------- ### Python Fetch Example Source: https://developers.cloudflare.com/queues/configuration/pull-consumers/index.md A basic Python example using the 'workers' library to fetch data, likely for interacting with Cloudflare services. ```python import json from workers import fetch ``` -------------------------------- ### Install Robots Parser Source: https://developers.cloudflare.com/queues/tutorials/web-crawler-with-browser-run/index.md Install the robots-parser package to handle robots.txt files. This command is for npm. ```bash npm i robots-parser ``` -------------------------------- ### Install Resend Package (pnpm) Source: https://developers.cloudflare.com/queues/tutorials/handle-rate-limits Install the Resend package using pnpm to enable email sending functionality. ```bash pnpm add resend ``` -------------------------------- ### Install Resend Package (npm) Source: https://developers.cloudflare.com/queues/tutorials/handle-rate-limits Install the Resend package using npm to enable email sending functionality. ```bash npm i resend ``` -------------------------------- ### Install Resend Package Source: https://developers.cloudflare.com/queues/tutorials/handle-rate-limits/index.md Install the Resend package using npm, yarn, pnpm, or bun to use its email sending capabilities. ```bash npm i resend ``` ```bash yarn add resend ``` ```bash pnpm add resend ``` ```bash bun add resend ``` -------------------------------- ### Start Local Development Session Source: https://developers.cloudflare.com/queues/configuration/local-development/index.md Run this command in your terminal to start a local development session for Cloudflare Queues. This simulates your Worker and resources locally using Miniflare. ```bash npx wrangler@latest dev ``` -------------------------------- ### Install Cloudflare Puppeteer with bun Source: https://developers.cloudflare.com/queues/tutorials/web-crawler-with-browser-run Install the Cloudflare fork of Puppeteer using bun. This is required for Browser Run functionality. ```bash bun add -d @cloudflare/puppeteer ``` -------------------------------- ### Install robots-parser with bun Source: https://developers.cloudflare.com/queues/tutorials/web-crawler-with-browser-run Install the robots-parser package using bun. This is often used in web crawling to respect robots.txt rules. ```bash bun add robots-parser ``` -------------------------------- ### Start Local Development for Multiple Workers Source: https://developers.cloudflare.com/queues/configuration/local-development Use this command to start local development servers for multiple Workers simultaneously, useful for testing producer-consumer patterns. Specify configuration files for each worker. ```bash npx wrangler@latest dev -c wrangler.jsonc -c consumer-worker/wrangler.jsonc --persist-to .wrangler/state ``` -------------------------------- ### Start Local Development Session with Wrangler Source: https://developers.cloudflare.com/queues/configuration/local-development Run this command in your terminal to start a local development session for your Worker. This simulates the production environment locally using Miniflare. ```bash npx wrangler@latest dev ``` -------------------------------- ### KV Namespace Creation Output Example Source: https://developers.cloudflare.com/queues/tutorials/web-crawler-with-browser-run This output shows the successful creation of KV namespaces and provides the necessary configuration for your Wrangler file. ```text 🌀 Creating namespace with title "web-crawler-crawler-links" ✨ Success! Add the following to your configuration file in your kv_namespaces array: [[kv_namespaces]] binding = "crawler_links" id = "" 🌀 Creating namespace with title "web-crawler-crawler-screenshots" ✨ Success! Add the following to your configuration file in your kv_namespaces array: [[kv_namespaces]] binding = "crawler_screenshots" id = "" ``` -------------------------------- ### Install robots-parser with yarn Source: https://developers.cloudflare.com/queues/tutorials/web-crawler-with-browser-run Install the robots-parser package using yarn. This is often used in web crawling to respect robots.txt rules. ```bash yarn add robots-parser ``` -------------------------------- ### Durable Object Sending Messages to a Queue Source: https://developers.cloudflare.com/queues/llms-full.txt This example demonstrates how a Durable Object can send messages to a Cloudflare Queue. It includes the necessary imports, environment setup, and the logic for publishing messages. ```typescript import { DurableObject } from "cloudflare:workers"; interface Env { YOUR_QUEUE: Queue; YOUR_DO_CLASS: DurableObjectNamespace; } export default { async fetch(req, env, ctx): Promise { // Assume each Durable Object is mapped to a userId in a query parameter // In a production application, this will be a userId defined by your application // that you validate (and/or authenticate) first. const url = new URL(req.url); const userIdParam = url.searchParams.get("userId"); if (userIdParam) { // Get a stub that allows you to call that Durable Object const durableObjectStub = env.YOUR_DO_CLASS.getByName(userIdParam); // Pass the request to that Durable Object and await the response // This invokes the constructor once on your Durable Object class (defined further down) // on the first initialization, and the fetch method on each request. // We pass the original Request to the Durable Object's fetch method const response = await durableObjectStub.fetch(req); // This would return "wrote to queue", but you could return any response. return response; } return new Response("userId must be provided", { status: 400 }); }, } satisfies ExportedHandler; export class YourDurableObject extends DurableObject { async fetch(req: Request): Promise { // Error handling elided for brevity. // Publish to your queue await this.env.YOUR_QUEUE.send({ id: this.ctx.id.toString(), // Write the ID of the Durable Object to your queue // Write any other properties to your queue }); return new Response("wrote to queue"); } } ``` -------------------------------- ### Install Cloudflare Puppeteer with pnpm Source: https://developers.cloudflare.com/queues/tutorials/web-crawler-with-browser-run Install the Cloudflare fork of Puppeteer using pnpm. This is required for Browser Run functionality. ```bash pnpm add -D @cloudflare/puppeteer ``` -------------------------------- ### Install robots-parser with pnpm Source: https://developers.cloudflare.com/queues/tutorials/web-crawler-with-browser-run Install the robots-parser package using pnpm. This is often used in web crawling to respect robots.txt rules. ```bash pnpm add robots-parser ``` -------------------------------- ### Install Cloudflare Puppeteer with yarn Source: https://developers.cloudflare.com/queues/tutorials/web-crawler-with-browser-run Install the Cloudflare fork of Puppeteer using yarn. This is required for Browser Run functionality. ```bash yarn add -D @cloudflare/puppeteer ``` -------------------------------- ### Send messages with delays in Python Source: https://developers.cloudflare.com/queues/configuration/batching-retries/index.md Python examples for sending single and batch messages with specified delays using `delaySeconds`. ```python await env.YOUR_QUEUE.send(message, delaySeconds=600) ``` ```python await env.YOUR_QUEUE.sendBatch(messages, delaySeconds=300) ``` ```python await env.YOUR_QUEUE.sendBatch(messages, delaySeconds=0) ``` -------------------------------- ### Basic Queue Consumer in TypeScript Source: https://developers.cloudflare.com/queues/configuration/javascript-apis/index.md A basic example of a queue consumer Worker written in TypeScript, demonstrating how to handle messages and defining the environment bindings. ```typescript interface Env { // Add your bindings here } export default { async queue(batch, env, ctx): Promise { for (const message of batch.messages) { console.log("Received", message.body); } }, } satisfies ExportedHandler; ``` -------------------------------- ### Install Puppeteer for Browser Run Source: https://developers.cloudflare.com/queues/tutorials/web-crawler-with-browser-run/index.md Install Cloudflare's fork of Puppeteer to control a headless Chromium instance within your Worker. This command is for npm. ```bash npm i -D @cloudflare/puppeteer ``` -------------------------------- ### Basic Queue Consumer in JavaScript Source: https://developers.cloudflare.com/queues/configuration/javascript-apis/index.md A basic example of a queue consumer Worker that iterates through messages in a batch and logs their bodies. ```javascript export default { async queue(batch, env, ctx) { for (const message of batch.messages) { console.log("Received", message.body); } }, }; ``` -------------------------------- ### Wrangler Development Server Output Source: https://developers.cloudflare.com/queues/tutorials/handle-rate-limits Example output from the Wrangler development server showing a successful request and the processed queue message. ```text [wrangler:inf] POST / 200 OK (2ms) QueueMessage { attempts: 1, body: { email: 'test@example.com' }, timestamp: 2024-09-12T13:48:07.236Z, id: '72a25ff18dd441f5acb6086b9ce87c8c' } ``` -------------------------------- ### Send a message to a queue Source: https://developers.cloudflare.com/queues/reference/how-queues-works/index.md This example shows how to bind a queue to a Worker and send a single message to it. The message is sent asynchronously. ```typescript interface Env { readonly MY_FIRST_QUEUE: Queue; } export default { async fetch(req, env, ctx): Promise { const message = { url: req.url, method: req.method, headers: Object.fromEntries(req.headers), }; await env.MY_FIRST_QUEUE.send(message); // This will throw an exception if the send fails for any reason return new Response("Sent!"); }, } satisfies ExportedHandler; ``` -------------------------------- ### Send Single Message to Queue (Python) Source: https://developers.cloudflare.com/queues/configuration/javascript-apis An example using Python with Pyodide to send a single message to a Cloudflare Queue. ```python from pyodide.ffi import to_js from workers import Response, WorkerEntrypoint class Default(WorkerEntrypoint): async def fetch(self, request): await self.env.MY_QUEUE.send(to_js({ "url": request.url, "method": request.method, "headers": dict(request.headers), })) return Response("Sent!") ``` -------------------------------- ### Basic Queue Consumer in Python Source: https://developers.cloudflare.com/queues/configuration/javascript-apis/index.md A basic example of a queue consumer Worker implemented in Python using the Workers framework, logging received messages. ```python from workers import WorkerEntrypoint class Default(WorkerEntrypoint): async def queue(self, batch): for message in batch.messages: print("Received", message) ``` -------------------------------- ### Cloudflare Queue Creation Response Source: https://developers.cloudflare.com/queues/llms-full.txt This is an example JSON response indicating the successful creation of a queue or an error encountered during the process. ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "consumers": [ { "consumer_id": "023e105f4ecef8ad9ca31a8372d0c353", "created_on": "2019-12-27T18:11:19.117Z", "dead_letter_queue": "dead_letter_queue", "queue_name": "example-queue", "script_name": "my-consumer-worker", "settings": { "batch_size": 50, "max_concurrency": 10, "max_retries": 3, "max_wait_time_ms": 5000, "retry_delay": 10 }, "type": "worker" } ], "consumers_total_count": 0, "created_on": "created_on", "modified_on": "modified_on", "producers": [ { "script": "script", "type": "worker" } ], "producers_total_count": 0, "queue_id": "queue_id", "queue_name": "example-queue", "settings": { "delivery_delay": 5, "delivery_paused": true, "message_retention_period": 345600 } }, "success": true } ``` -------------------------------- ### Wrangler configuration for queue consumer (JSON) Source: https://developers.cloudflare.com/queues/reference/how-queues-works Configure a queue consumer using a `[[queues.consumers]]` section in your `wrangler.toml` file. This example shows the JSON format. ```json { "queues": { "consumers": [ { "queue": "", "max_batch_size": 100, // optional "max_batch_timeout": 30 // optional } ] } } ``` -------------------------------- ### Complete wrangler.toml configuration for web crawler Source: https://developers.cloudflare.com/queues/tutorials/web-crawler-with-browser-run This is a comprehensive example of a wrangler.toml file for a web crawler, including KV namespaces, Browser Run binding, and Queue configurations. ```toml "$schema" = "./node_modules/wrangler/config-schema.json" name = "web-crawler" main = "src/index.ts" # Set this to today's date compatibility_date = "2026-06-16" compatibility_flags = [ "nodejs_compat" ] [[kv_namespaces]] binding = "CRAWLER_SCREENSHOTS_KV" id = "" [[kv_namespaces]] binding = "CRAWLER_LINKS_KV" id = "" [browser] binding = "CRAWLER_BROWSER" [[queues.consumers]] queue = "queues-web-crawler" max_batch_timeout = 60 [[queues.producers]] queue = "queues-web-crawler" binding = "CRAWLER_QUEUE" ``` -------------------------------- ### queues subscription get Source: https://developers.cloudflare.com/queues/llms-full.txt Retrieves details for a specific event subscription in a Cloudflare Queue. ```APIDOC ## `queues subscription get` ### Description Get details about a specific event subscription. ### Method GET ### Endpoint `/queues/get/subscription` (This is an inferred endpoint based on the command structure, actual endpoint may vary) ### Parameters #### Path Parameters None #### Query Parameters - **QUEUE** (string) - Required - The name of the queue. - **id** (string) - Required - The ID of the subscription to retrieve. - **json** (boolean) - Optional - Output in JSON format. Defaults to false. ### Request Example ```bash npx wrangler queues subscription get QUEUE --id SUBSCRIPTION_ID ``` ### Response #### Success Response (200) Details about the specified event subscription. #### Response Example ```json { "id": "string", "queue_name": "string", "destination_exchange": "string", "destination_routing_key": "string", "created_on": "string", "last_modified_on": "string" } ``` ``` -------------------------------- ### Send Test Message to Worker Source: https://developers.cloudflare.com/queues/llms-full.txt Example using curl to send a JSON payload to the deployed Worker, which will then publish it to the queue. ```bash # Make sure to replace the placeholder with your shared secret curl -XPOST "https://YOUR_WORKER.YOUR_ACCOUNT.workers.dev" --data '{"messages": [{"msg":"hello world"}]}' ``` -------------------------------- ### Acknowledge and Retry Messages with Delay Source: https://developers.cloudflare.com/queues/configuration/pull-consumers/index.md This example demonstrates how to acknowledge messages and retry specific messages with a defined delay in seconds. This is useful for handling temporary processing issues. ```json { "acks": [ { "lease_id": "lease_id1" }, { "lease_id": "lease_id2" }, { "lease_id": "lease_id3" } ], "retries": [{ "lease_id": "lease_id4", "delay_seconds": 600 }] } ``` -------------------------------- ### Send Single Message to Queue with Type Hinting (TypeScript) Source: https://developers.cloudflare.com/queues/configuration/javascript-apis This TypeScript example demonstrates sending a single message to a Queue, including type safety for the environment and message. ```typescript interface Env { readonly MY_QUEUE: Queue; } export default { async fetch(req, env, ctx): Promise { await env.MY_QUEUE.send({ url: req.url, method: req.method, headers: Object.fromEntries(req.headers), }); return new Response("Sent!"); }, } satisfies ExportedHandler; ``` -------------------------------- ### Send Single Message to Queue (Python) Source: https://developers.cloudflare.com/queues/configuration/javascript-apis/index.md A Python example for sending a single message containing request details to a Cloudflare Queue. This requires the pyodide.ffi library for interoperability. ```python from pyodide.ffi import to_js from workers import Response, WorkerEntrypoint class Default(WorkerEntrypoint): async def fetch(self, request): await self.env.MY_QUEUE.send(to_js({ "url": request.url, "method": request.method, "headers": dict(request.headers), })) return Response("Sent!") ``` -------------------------------- ### Fetch Documentation Index Source: https://developers.cloudflare.com/queues/llms-full.txt This command-line instruction shows how to fetch the complete documentation index for Cloudflare Workers, which can be used to discover available pages. ```bash curl https://developers.cloudflare.com/workers/llms.txt ``` -------------------------------- ### Delay a Batch of Messages on Send (Python) Source: https://developers.cloudflare.com/queues/llms-full.txt Use the `sendBatch` method with the `delaySeconds` keyword argument to defer a batch of messages. This example delays a batch by 5 minutes. ```python await env.YOUR_QUEUE.sendBatch(messages, delaySeconds=300) ``` -------------------------------- ### Process Messages in Queue Handler Source: https://developers.cloudflare.com/queues/llms-full.txt Implement the queue handler to process messages from the queue. This example logs the email, acknowledges the message, and includes basic error handling with retries. ```typescript interface Message { email: string; } export default { async fetch(req, env, ctx): Promise { try { await env.EMAIL_QUEUE.send( { email: await req.text() }, { delaySeconds: 1 }, ); return new Response("Success!"); } catch (e) { return new Response("Error!", { status: 500 }); } }, async queue(batch, env, ctx): Promise { for (const message of batch.messages) { try { console.log(message.body.email); // After configuring Resend, you can send email message.ack(); } catch (e) { console.error(e); message.retry({ delaySeconds: 5 }); } } }, } satisfies ExportedHandler; ``` -------------------------------- ### Delay a Singular Message on Send (Python) Source: https://developers.cloudflare.com/queues/llms-full.txt In Python, use the `send` method with the `delaySeconds` keyword argument to defer a single message. This example delays a message by 10 minutes. ```python await env.YOUR_QUEUE.send(message, delaySeconds=600) ``` -------------------------------- ### List Queues with npm Source: https://developers.cloudflare.com/queues/reference/wrangler-commands/index.md Use this command to list all available queues in your Cloudflare project using npm. ```bash npx wrangler queues list ``` -------------------------------- ### Navigate to the new application directory Source: https://developers.cloudflare.com/queues/tutorials/web-crawler-with-browser-run/index.md After creating the Workers application, change into the new project directory using the cd command. ```bash cd queues-web-crawler ``` -------------------------------- ### Create a new Cloudflare Worker project using pnpm Source: https://developers.cloudflare.com/queues/tutorials/handle-rate-limits Use the create-cloudflare CLI with pnpm to scaffold a new Worker project. Select 'Hello World example', 'Worker only', 'TypeScript', and 'Yes' for Git, but 'No' for initial deployment. ```bash pnpm create cloudflare@latest resend-rate-limit-queue ``` -------------------------------- ### Create a new Cloudflare Worker project using npm Source: https://developers.cloudflare.com/queues/tutorials/handle-rate-limits Use the create-cloudflare CLI with npm to scaffold a new Worker project. Select 'Hello World example', 'Worker only', 'TypeScript', and 'Yes' for Git, but 'No' for initial deployment. ```bash npm create cloudflare@latest -- resend-rate-limit-queue ``` -------------------------------- ### Pull Messages with Visibility Timeout and Batch Size (Python) Source: https://developers.cloudflare.com/queues/llms-full.txt This Python code snippet shows how to pull messages from a queue using the Cloudflare workers fetch utility. It includes options for setting the visibility timeout and batch size. Ensure the 'workers' library is installed. ```python import json from workers import fetch # POST /accounts/${CF_ACCOUNT_ID}/queues/${QUEUE_ID}/messages/pull with the timeout & batch size resp = await fetch( f"https://api.cloudflare.com/client/v4/accounts/{CF_ACCOUNT_ID}/queues/{QUEUE_ID}/messages/pull", method="POST", headers={ "content-type": "application/json", "authorization": f"Bearer {QUEUES_API_TOKEN}", }, # Optional - you can provide an empty object '{}' and the defaults will apply. body=json.dumps({"visibility_timeout_ms": 6000, "batch_size": 50}), ) ``` -------------------------------- ### Send a JSON Message with Explicit Content Type Source: https://developers.cloudflare.com/queues/llms-full.txt This example shows how to explicitly set the content type to JSON when sending a message to a Cloudflare Queue. It includes error handling for send failures. ```typescript interface Env { readonly MY_FIRST_QUEUE: Queue; } export default { async fetch(req, env, ctx): Promise { const message = { url: req.url, method: req.method, headers: Object.fromEntries(req.headers), }; try { await env.MY_FIRST_QUEUE.send(message, { contentType: "json" }); // "json" is the default return new Response("Sent!"); } catch (e) { // Catch cases where send fails, including due to a mismatched content type const msg = e instanceof Error ? e.message : "Unknown error"; return Response.json({ error: msg }, { status: 500 }); } }, } satisfies ExportedHandler; ``` -------------------------------- ### Workers Build Started Event Schema Source: https://developers.cloudflare.com/queues/event-subscriptions/events-schemas/index.md This schema indicates that a worker build process has started. It includes build metadata such as the trigger source, commit details, and commands. ```json { "type": "cf.workersBuilds.worker.build.started", "source": { "type": "workersBuilds.worker", "workerName": "my-worker" }, "payload": { "buildUuid": "build-12345678-90ab-cdef-1234-567890abcdef", "status": "running", "buildOutcome": null, "createdAt": "2025-05-01T02:48:57.132Z", "initializingAt": "2025-05-01T02:48:58.132Z", "runningAt": "2025-05-01T02:48:59.132Z", "stoppedAt": null, "buildTriggerMetadata": { "buildTriggerSource": "push_event", "branch": "main", "commitHash": "abc123def456", "commitMessage": "Fix bug in authentication", "author": "developer@example.com", "buildCommand": "npm run build", "deployCommand": "wrangler deploy", "rootDirectory": "/", "repoName": "my-worker-repo", "providerAccountName": "github-user", "providerType": "github" } }, "metadata": { "accountId": "f9f79265f388666de8122cfb508d7776", "eventSubscriptionId": "1830c4bb612e43c3af7f4cada31fbf3f", "eventSchemaVersion": 1, "eventTimestamp": "2025-05-01T02:48:57.132Z" } } ``` -------------------------------- ### Create a Queue with npm Source: https://developers.cloudflare.com/queues/reference/wrangler-commands/index.md Use this command to create a new queue with a specified name using npm. You can also configure delivery delay and message retention. ```bash npx wrangler queues create [NAME] ``` -------------------------------- ### Super Slurper Job Started Event Schema Source: https://developers.cloudflare.com/queues/event-subscriptions/events-schemas/index.md Schema for events triggered when a Super Slurper migration job starts. Includes job ID, creation timestamp, and overwrite flag. ```json { "type": "cf.superSlurper.job.started", "source": { "type": "superSlurper" }, "payload": { "id": "job-12345678-90ab-cdef-1234-567890abcdef", "createdAt": "2025-05-01T02:48:57.132Z", "overwrite": true } } ``` -------------------------------- ### Create a new event subscription using pnpm Source: https://developers.cloudflare.com/queues/reference/wrangler-commands Use this command to create a new event subscription for a queue. Required arguments include the queue name `[QUEUE]`, the event source type `--source`, and the event types `--events`. An optional name can be provided with `--name`. ```bash pnpm wrangler queues subscription create [QUEUE] ``` -------------------------------- ### Create a new event subscription using npx Source: https://developers.cloudflare.com/queues/reference/wrangler-commands Use this command to create a new event subscription for a queue. Required arguments include the queue name `[QUEUE]`, the event source type `--source`, and the event types `--events`. An optional name can be provided with `--name`. ```bash npx wrangler queues subscription create [QUEUE] ``` -------------------------------- ### Tail Worker Logs Source: https://developers.cloudflare.com/queues/get-started/index.md Start tailing logs for your Worker to observe messages being processed. This is useful for debugging and monitoring. ```bash npx wrangler tail ``` -------------------------------- ### Create Queue Subscription Source: https://developers.cloudflare.com/queues/reference/wrangler-commands/index.md Use this command to create a new event subscription for a specified queue. The queue name is a required string argument. ```bash npx wrangler queues subscription create [QUEUE] ``` ```bash pnpm wrangler queues subscription create [QUEUE] ``` ```bash yarn wrangler queues subscription create [QUEUE] ``` -------------------------------- ### Complete Wrangler configuration with Queue bindings (TOML) Source: https://developers.cloudflare.com/queues/tutorials/handle-rate-limits This is the complete Wrangler.toml configuration, including project name, main file, compatibility date, flags, and the detailed queue producer and consumer bindings. ```toml "$schema" = "./node_modules/wrangler/config-schema.json" name = "resend-rate-limit-queue" main = "src/index.ts" compatibility_date = "2026-06-16" compatibility_flags = [ "nodejs_compat" ] [[queues.producers]] binding = "EMAIL_QUEUE" queue = "rate-limit-queue" [[queues.consumers]] queue = "rate-limit-queue" max_batch_size = 2 max_batch_timeout = 10 max_retries = 3 ``` -------------------------------- ### Create a new Cloudflare Worker project using yarn Source: https://developers.cloudflare.com/queues/tutorials/handle-rate-limits Use the create-cloudflare CLI with yarn to scaffold a new Worker project. Select 'Hello World example', 'Worker only', 'TypeScript', and 'Yes' for Git, but 'No' for initial deployment. ```bash yarn create cloudflare resend-rate-limit-queue ``` -------------------------------- ### Create Event Subscription with Wrangler CLI Source: https://developers.cloudflare.com/queues/event-subscriptions/manage-event-subscriptions/index.md Use this command to create a new event subscription for a specified queue, including source and events. ```bash npx wrangler queues subscription create --source --events -- ``` -------------------------------- ### Get Information About a Cloudflare Queue Source: https://developers.cloudflare.com/queues/reference/wrangler-commands/index.md Use this command to retrieve information about a specific queue. Requires the queue name as an argument. ```bash npx wrangler queues info [NAME] ``` ```bash pnpm wrangler queues info [NAME] ``` ```bash yarn wrangler queues info [NAME] ``` -------------------------------- ### List Consumers for a Queue using npm Source: https://developers.cloudflare.com/queues/reference/wrangler-commands/index.md Use this command to list all consumers associated with a specific Cloudflare Queue. Requires npm. ```bash npx wrangler queues consumer list [QUEUE-NAME] ``` -------------------------------- ### Navigate to the new Worker project directory Source: https://developers.cloudflare.com/queues/tutorials/handle-rate-limits Change the current directory to the newly created Worker project folder. ```bash cd resend-rate-limit-queue ``` -------------------------------- ### Create a Cloudflare Queue Source: https://developers.cloudflare.com/queues/get-started/index.md Use the Wrangler CLI to create a new queue. Replace with a descriptive name for your queue. Queue names have specific length and character restrictions. ```bash npx wrangler queues create ``` -------------------------------- ### Configure Resend API Key Source: https://developers.cloudflare.com/queues/tutorials/handle-rate-limits Add your Resend API key to the .dev.vars file for local development. ```bash RESEND_API_KEY='your-resend-api-key' ``` -------------------------------- ### Send Multiple Messages to Queue (Python) Source: https://developers.cloudflare.com/queues/configuration/javascript-apis This Python example demonstrates sending a batch of messages to a Cloudflare Queue using `sendBatch`. ```python from pyodide.ffi import to_js async def send_results_to_queue(results, env): batch = [ {"body": value} for value in results ] await env.MY_QUEUE.sendBatch(to_js(batch)) ``` -------------------------------- ### Complete Wrangler configuration with Queue bindings (JSON) Source: https://developers.cloudflare.com/queues/tutorials/handle-rate-limits This is the complete Wrangler.json configuration, including project name, main file, compatibility date, flags, and the detailed queue producer and consumer bindings. ```json { "$schema": "./node_modules/wrangler/config-schema.json", "name": "resend-rate-limit-queue", "main": "src/index.ts", "compatibility_date": "2026-06-16", "compatibility_flags": [ "nodejs_compat" ], "queues": { "producers": [ { "binding": "EMAIL_QUEUE", "queue": "rate-limit-queue" } ], "consumers": [ { "queue": "rate-limit-queue", "max_batch_size": 2, "max_batch_timeout": 10, "max_retries": 3 } ] } } ``` -------------------------------- ### Configure Queue Consumer Settings (TOML) Source: https://developers.cloudflare.com/queues/get-started/index.md Configure queue name, batch size, and batch timeout for your consumer Worker. Defaults are provided for batch size and timeout. ```toml [[queues.consumers]] queue = "" max_batch_size = 10 max_batch_timeout = 5 ``` -------------------------------- ### Get Queue Information using yarn Source: https://developers.cloudflare.com/queues/reference/wrangler-commands Use this command to retrieve information about a specific queue. Requires the queue name as an argument. ```bash yarn wrangler queues info [NAME] ```