Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Comprehensive Cloudflare platform skill covering Workers, D1, R2, KV, AI, Durable Objects, and security.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/queues/README.md
1# Cloudflare Queues23Flexible message queuing for async task processing with guaranteed at-least-once delivery and configurable batching.45## Overview67Queues provide:8- At-least-once delivery guarantee9- Push-based (Worker) and pull-based (HTTP) consumers10- Configurable batching and retries11- Dead Letter Queues (DLQ)12- Delays up to 12 hours1314**Use cases:** Async processing, API buffering, rate limiting, event workflows, deferred jobs1516## Quick Start1718```bash19wrangler queues create my-queue20wrangler queues consumer add my-queue my-worker21```2223```typescript24// Producer25await env.MY_QUEUE.send({ userId: 123, action: 'notify' });2627// Consumer (with proper error handling)28export default {29async queue(batch: MessageBatch, env: Env): Promise<void> {30for (const msg of batch.messages) {31try {32await process(msg.body);33msg.ack();34} catch (error) {35msg.retry({ delaySeconds: 60 });36}37}38}39};40```4142## Critical Warnings4344**Before using Queues, understand these production mistakes:**45461. **Uncaught errors retry ENTIRE batch** (not just failed message). Always use per-message try/catch.472. **Messages not ack'd/retry'd will auto-retry forever** until max_retries. Always explicitly handle each message.4849See [gotchas.md](./gotchas.md) for detailed solutions.5051## Core Operations5253| Operation | Purpose | Limit |54|-----------|---------|-------|55| `send(body, options?)` | Publish message | 128 KB |56| `sendBatch(messages)` | Bulk publish | 100 msgs/256 KB |57| `message.ack()` | Acknowledge success | - |58| `message.retry(options?)` | Retry with delay | - |59| `batch.ackAll()` | Ack entire batch | - |6061## Architecture6263```64[Producer Worker] → [Queue] → [Consumer Worker/HTTP] → [Processing]65```6667- Max 10,000 queues per account68- 5,000 msgs/second per queue69- 4-14 day retention (configurable)7071## Reading Order7273**New to Queues?** Start here:741. [configuration.md](./configuration.md) - Set up queues, bindings, consumers752. [api.md](./api.md) - Send messages, handle batches, ack/retry patterns763. [patterns.md](./patterns.md) - Real-world examples and integrations774. [gotchas.md](./gotchas.md) - Critical warnings and troubleshooting7879**Task-based routing:**80- Setup queue → [configuration.md](./configuration.md)81- Send/receive messages → [api.md](./api.md)82- Implement specific pattern → [patterns.md](./patterns.md)83- Debug/troubleshoot → [gotchas.md](./gotchas.md)8485## In This Reference8687- [configuration.md](./configuration.md) - wrangler.jsonc setup, producer/consumer config, DLQ, content types88- [api.md](./api.md) - Send/batch methods, queue handler, ack/retry rules, type-safe patterns89- [patterns.md](./patterns.md) - Async tasks, buffering, rate limiting, D1/Workflows/DO integrations90- [gotchas.md](./gotchas.md) - Critical batch error handling, idempotency, error classification9192## See Also9394- [workers](../workers/) - Worker runtime for producers/consumers95- [r2](../r2/) - Process R2 event notifications via queues96- [d1](../d1/) - Batch write to D1 from queue consumers97