|
|
3 dias atrás | |
|---|---|---|
| .. | ||
| README.md | 3 dias atrás | |
| api.md | 3 dias atrás | |
| configuration.md | 3 dias atrás | |
| gotchas.md | 3 dias atrás | |
| patterns.md | 3 dias atrás | |
Flexible message queuing for async task processing with guaranteed at-least-once delivery and configurable batching.
Queues provide:
Use cases: Async processing, API buffering, rate limiting, event workflows, deferred jobs
wrangler queues create my-queue
wrangler queues consumer add my-queue my-worker
// Producer
await env.MY_QUEUE.send({ userId: 123, action: 'notify' });
// Consumer (with proper error handling)
export default {
async queue(batch: MessageBatch, env: Env): Promise<void> {
for (const msg of batch.messages) {
try {
await process(msg.body);
msg.ack();
} catch (error) {
msg.retry({ delaySeconds: 60 });
}
}
}
};
Before using Queues, understand these production mistakes:
See gotchas.md for detailed solutions.
| Operation | Purpose | Limit |
|---|---|---|
send(body, options?) |
Publish message | 128 KB |
sendBatch(messages) |
Bulk publish | 100 msgs/256 KB |
message.ack() |
Acknowledge success | - |
message.retry(options?) |
Retry with delay | - |
batch.ackAll() |
Ack entire batch | - |
[Producer Worker] → [Queue] → [Consumer Worker/HTTP] → [Processing]
New to Queues? Start here:
Task-based routing: