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/configuration.md
1# Queues Configuration23## Create Queue45```bash6wrangler queues create my-queue7wrangler queues create my-queue --retention-period-hours=336 # 14 days8wrangler queues create my-queue --delivery-delay-secs=3009```1011## Producer Binding1213**wrangler.jsonc:**14```jsonc15{16"queues": {17"producers": [18{19"queue": "my-queue-name",20"binding": "MY_QUEUE",21"delivery_delay": 60 // Optional: default delay in seconds22}23]24}25}26```2728## Consumer Configuration (Push-based)2930**wrangler.jsonc:**31```jsonc32{33"queues": {34"consumers": [35{36"queue": "my-queue-name",37"max_batch_size": 10, // 1-100, default 1038"max_batch_timeout": 5, // 0-60s, default 539"max_retries": 3, // default 3, max 10040"dead_letter_queue": "my-dlq", // optional41"retry_delay": 300 // optional: delay retries in seconds42}43]44}45}46```4748## Consumer Configuration (Pull-based)4950**wrangler.jsonc:**51```jsonc52{53"queues": {54"consumers": [55{56"queue": "my-queue-name",57"type": "http_pull",58"visibility_timeout_ms": 5000, // default 30000, max 12h59"max_retries": 5,60"dead_letter_queue": "my-dlq"61}62]63}64}65```6667## TypeScript Types6869```typescript70interface Env {71MY_QUEUE: Queue<MessageBody>;72ANALYTICS_QUEUE: Queue<AnalyticsEvent>;73}7475interface MessageBody {76id: string;77action: 'create' | 'update' | 'delete';78data: Record<string, any>;79}8081export default {82async queue(batch: MessageBatch<MessageBody>, env: Env): Promise<void> {83for (const msg of batch.messages) {84console.log(msg.body.action);85msg.ack();86}87}88} satisfies ExportedHandler<Env>;89```9091## Content Type Selection9293Choose content type based on consumer type and data requirements:9495| Content Type | Use When | Readable By | Supports | Size |96|--------------|----------|-------------|----------|------|97| `json` | Pull consumers, dashboard visibility, simple objects | All (push/pull/dashboard) | JSON-serializable types only | Medium |98| `v8` | Push consumers only, complex JS objects | Push consumers only | Date, Map, Set, BigInt, typed arrays | Small |99| `text` | String-only payloads | All | Strings only | Smallest |100| `bytes` | Binary data (images, files) | All | ArrayBuffer, Uint8Array | Variable |101102**Decision tree:**1031. Need to view in dashboard or use pull consumer? → Use `json`1042. Need Date, Map, Set, or other V8 types? → Use `v8` (push consumers only)1053. Just strings? → Use `text`1064. Binary data? → Use `bytes`107108```typescript109// JSON: Good for simple objects, pull consumers, dashboard visibility110await env.QUEUE.send({ id: 123, name: 'test' }, { contentType: 'json' });111112// V8: Good for Date, Map, Set (push consumers only)113await env.QUEUE.send({114created: new Date(),115tags: new Set(['a', 'b'])116}, { contentType: 'v8' });117118// Text: Simple strings119await env.QUEUE.send('process-user-123', { contentType: 'text' });120121// Bytes: Binary data122await env.QUEUE.send(imageBuffer, { contentType: 'bytes' });123```124125**Default behavior:** If not specified, Cloudflare auto-selects `json` for JSON-serializable objects and `v8` for complex types.126127**IMPORTANT:** `v8` messages cannot be read by pull consumers or viewed in the dashboard. Use `json` if you need visibility or pull-based consumption.128129## CLI Commands130131```bash132# Consumer management133wrangler queues consumer add my-queue my-worker --batch-size=50 --max-retries=5134wrangler queues consumer http add my-queue135wrangler queues consumer worker remove my-queue my-worker136wrangler queues consumer http remove my-queue137138# Queue operations139wrangler queues list140wrangler queues pause my-queue141wrangler queues resume my-queue142wrangler queues purge my-queue143wrangler queues delete my-queue144```145