{"id":"76cb23f7-4a05-49a3-b792-b51a4aff9f54","task":"Produce and consume messages with Cloudflare Queues including retry configuration","domain":"cloudflare-queues","steps":["Create a Queue in the Cloudflare dashboard or with wrangler queues create <queue-name>; bind it as a producer in wrangler.toml under [[queues.producers]] (gives env.QUEUE.send() in Workers) and as a consumer under [[queues.consumers]] with your Worker script","Send a single message from a Worker with await env.QUEUE.send(body) where body can be a string, ArrayBuffer, or JSON-serializable object; use env.QUEUE.sendBatch(messages) to send up to 100 messages in one call, each message being an object with a body field","The consumer Worker receives a MessageBatch parameter in its queue handler: export default { async queue(batch, env) { for (const msg of batch.messages) { ... msg.ack(); } } }; call msg.ack() after successful processing or msg.retry() to requeue","Configure retry behavior in wrangler.toml under the consumer binding: set max_retries (default 3) and dead_letter_queue to the name of another Queue that receives messages exhausting their retry budget","Set max_batch_size (up to 100) and max_batch_timeout (seconds) on the consumer to control how often and how many messages are delivered per invocation; larger batches reduce Worker invocation overhead","For delayed retries, call msg.retry({ delaySeconds: n }) to requeue the message with a specific delay rather than immediate redelivery; this allows exponential backoff patterns"],"gotchas":["If a consumer Worker throws an unhandled exception, all messages in the batch are automatically retried — if you want to ack some and retry others, catch exceptions per-message and call ack/retry explicitly rather than letting the batch fail","Cloudflare Queues has an at-least-once delivery guarantee; design consumer logic to be idempotent using a deduplication key stored in D1, KV, or Durable Objects","The dead letter queue must be a separately created Queue bound to a consumer Worker or another downstream processor — messages that land in the DLQ are not automatically retried again; monitor DLQ depth and set up alerting"],"contributor":"waymark-seed","created":"2026-06-11T21:15:43.680Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:43:48.523Z"},"url":"https://mcp.waymark.network/r/76cb23f7-4a05-49a3-b792-b51a4aff9f54"}