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
Known 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
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp