Interactive wizard to set up Cloudflare Queues with queue creation, producer/consumer binding configuration, and Dead Letter Queue setup. Use when user wants to create first queue or add queues to existing Worker.
Sets up Cloudflare Queues with queue creation, producer/consumer bindings, and Dead Letter Queue configuration.
/plugin marketplace add secondsky/claude-skills/plugin install cloudflare-queues@claude-skillsInteractive wizard for complete Cloudflare Queues setup: create queue, configure producer/consumer bindings, set up DLQ, and provide example code.
Check before starting:
wrangler whoami)Use AskUserQuestion to collect setup preferences.
Question 1: Queue Name
queueNameQuestion 2: Queue Purpose
queuePurposeQuestion 3: Consumer Settings (if purpose includes consumer)
consumerSettingsQuestion 4: Dead Letter Queue
enableDLQExecute wrangler command based on user inputs:
# Create main queue
wrangler queues create <queueName>
Capture output: Extract queue creation confirmation
Error Handling:
wrangler login first, then retrywrangler queues list then wrangler queues delete <name>Verify creation:
wrangler queues list
If enableDLQ is true:
# Create DLQ
wrangler queues create <queueName>-dlq
Verify:
wrangler queues list
If queuePurpose includes "Producer":
Check if wrangler.jsonc or wrangler.toml exists:
if [ -f "wrangler.jsonc" ]; then
CONFIG_FILE="wrangler.jsonc"
elif [ -f "wrangler.toml" ]; then
CONFIG_FILE="wrangler.toml"
else
# Ask user which format to create
CONFIG_FILE="wrangler.jsonc" # Default to JSON
fi
Add Producer Configuration:
If wrangler.jsonc:
Use Edit tool to add to queues.producers array (or create array if doesn't exist):
{
"queues": {
"producers": [
{
"binding": "<QUEUE_BINDING>", // e.g., "ORDER_QUEUE"
"queue": "<queueName>" // e.g., "order-processing"
}
]
}
}
Binding name suggestion: Convert queue name to SCREAMING_SNAKE_CASE
If wrangler.toml:
[[queues.producers]]
binding = "<QUEUE_BINDING>"
queue = "<queueName>"
Verify:
# Show configuration to user
cat wrangler.jsonc | grep -A 10 "queues"
If queuePurpose includes "Consumer":
Add Consumer Configuration based on consumerSettings:
Standard settings (batch: 10, retries: 3, concurrency: 1):
{
"queues": {
"consumers": [
{
"queue": "<queueName>",
"max_batch_size": 10,
"max_retries": 3,
"max_concurrency": 1,
"dead_letter_queue": "<queueName>-dlq" // If DLQ enabled
}
]
}
}
High throughput settings (batch: 50, retries: 1, concurrency: 5):
{
"queues": {
"consumers": [
{
"queue": "<queueName>",
"max_batch_size": 50,
"max_retries": 1,
"max_concurrency": 5,
"dead_letter_queue": "<queueName>-dlq" // If DLQ enabled
}
]
}
}
Low latency settings (batch: 1, retries: 3, concurrency: 1):
{
"queues": {
"consumers": [
{
"queue": "<queueName>",
"max_batch_size": 1,
"max_retries": 3,
"max_concurrency": 1,
"dead_letter_queue": "<queueName>-dlq" // If DLQ enabled
}
]
}
}
Custom settings: Use user-provided values
Omit DLQ field if enableDLQ is false.
Verify:
cat wrangler.jsonc | grep -A 15 "consumers"
Create src/types.ts (or add to existing) with Queue binding types:
If Producer only:
// src/types.ts
export interface Bindings {
<QUEUE_BINDING>: Queue;
// Example: ORDER_QUEUE: Queue;
}
If Consumer only:
// src/types.ts
import { MessageBatch } from '@cloudflare/workers-types';
export interface Bindings {
// Add other bindings here (DB, KV, etc.)
}
export interface QueueMessage {
// Define your message structure
type: string;
// Add other fields based on your use case
}
If Both:
// src/types.ts
import { MessageBatch } from '@cloudflare/workers-types';
export interface Bindings {
<QUEUE_BINDING>: Queue;
}
export interface QueueMessage {
type: string;
// Add fields based on your use case
}
Check if file exists:
if [ -f "src/types.ts" ]; then
# Append to existing file
else
# Create new file
fi
If Producer only:
Show example of sending messages:
// src/index.ts - Producer example
import { Hono } from 'hono';
type Bindings = {
<QUEUE_BINDING>: Queue;
};
const app = new Hono<{ Bindings: Bindings }>();
// Send single message
app.post('/send', async (c) => {
const body = await c.req.json();
await c.env.<QUEUE_BINDING>.send({
type: 'order-created',
orderId: body.orderId,
userId: body.userId,
timestamp: Date.now()
});
return c.json({ status: 'queued' });
});
// Send batch of messages
app.post('/send-batch', async (c) => {
const items = await c.req.json<Array<any>>();
await c.env.<QUEUE_BINDING>.sendBatch(
items.map(item => ({
body: {
type: 'batch-process',
itemId: item.id,
data: item.data
}
}))
);
return c.json({ status: 'queued', count: items.length });
});
export default app;
If Consumer only:
Show example of processing messages:
// src/index.ts - Consumer example
import { MessageBatch } from '@cloudflare/workers-types';
interface Bindings {
// Add your bindings (DB, KV, etc.)
}
export default {
async queue(batch: MessageBatch, env: Bindings, ctx: ExecutionContext): Promise<void> {
for (const message of batch.messages) {
try {
// Process message
const data = message.body;
console.log('Processing:', data);
// Your processing logic here
await processMessage(data, env);
// Explicitly ack (optional - auto-acks if no error)
message.ack();
} catch (error) {
console.error('Failed to process message:', error);
// Message will retry up to max_retries, then go to DLQ
message.retry();
}
}
}
};
async function processMessage(data: any, env: Bindings) {
// Your processing logic
console.log('Processing message:', data);
}
If Both (Producer + Consumer):
Show combined example:
// src/index.ts - Producer + Consumer
import { Hono } from 'hono';
import { MessageBatch } from '@cloudflare/workers-types';
type Bindings = {
<QUEUE_BINDING>: Queue;
};
const app = new Hono<{ Bindings: Bindings }>();
// Producer endpoint
app.post('/orders', async (c) => {
const order = await c.req.json();
await c.env.<QUEUE_BINDING>.send({
type: 'order-created',
orderId: order.id,
userId: order.userId,
timestamp: Date.now()
});
return c.json({ status: 'queued', orderId: order.id });
});
export default {
// HTTP handler
fetch: app.fetch,
// Queue consumer
async queue(batch: MessageBatch, env: Bindings): Promise<void> {
for (const message of batch.messages) {
try {
const data = message.body;
if (data.type === 'order-created') {
// Process order
console.log('Processing order:', data.orderId);
// Add your logic here
}
message.ack();
} catch (error) {
console.error('Failed:', error);
message.retry();
}
}
}
};
Success Message:
✅ Cloudflare Queues Setup Complete!
Queue Configuration:
- Queue: <queueName>
- Producer: env.<QUEUE_BINDING> (if applicable)
- Consumer: Active with <settings> (if applicable)
- DLQ: <queueName>-dlq (if enabled)
Files Modified:
- wrangler.jsonc (queue bindings added)
- src/types.ts (TypeScript types added)
Next Steps:
1. Review the example code above and integrate into your Worker
2. Deploy your Worker:
```bash
wrangler deploy
Test message publishing (if producer):
curl -X POST https://your-worker.workers.dev/send \
-H "Content-Type: application/json" \
-d '{"orderId": "12345", "userId": "user_789"}'
Monitor queue status:
wrangler queues info <queueName>
View consumer logs:
wrangler tail
Check DLQ for failures (if enabled):
wrangler queues info <queueName>-dlq
📚 Helpful Resources:
templates/queues-producer.ts and templates/queues-consumer-basic.tsreferences/error-catalog.mdreferences/best-practices.mdreferences/limits-quotas.md💡 Tips:
wrangler queues info <queue-name>
---
## Error Handling
### Wrangler Not Authenticated
❌ Error: Not authenticated
Solution:
### Queue Already Exists
❌ Error: Queue '<queueName>' already exists
Solution:
### Invalid Configuration
❌ Error: Invalid wrangler.jsonc syntax
Solution:
### Queue Limit Reached
❌ Error: Account queue limit reached (10 queues on free plan)
Solutions:
---
## Example Full Workflow
**User Input**:
- Queue name: "order-processing"
- Purpose: Both producer and consumer
- Consumer settings: Standard
- DLQ: Yes
**Executed Commands**:
```bash
# 1. Create main queue
wrangler queues create order-processing
# Output: ✅ Created queue 'order-processing'
# 2. Create DLQ
wrangler queues create order-processing-dlq
# Output: ✅ Created queue 'order-processing-dlq'
# 3. Verify
wrangler queues list
# Output:
# order-processing
# order-processing-dlq
wrangler.jsonc (after setup):
{
"name": "my-worker",
"main": "src/index.ts",
"compatibility_date": "2025-01-15",
"queues": {
"producers": [
{
"binding": "ORDER_QUEUE",
"queue": "order-processing"
}
],
"consumers": [
{
"queue": "order-processing",
"max_batch_size": 10,
"max_retries": 3,
"max_concurrency": 1,
"dead_letter_queue": "order-processing-dlq"
}
]
}
}
Result:
✅ Setup complete!
- Queue: order-processing
- Producer: env.ORDER_QUEUE
- Consumer: batch_size=10, retries=3, concurrency=1
- DLQ: order-processing-dlq
Deploy with: wrangler deploy
This command provides interactive Cloudflare Queues setup through 8 guided steps:
Output: Fully configured queue ready for use, with helpful code examples and next steps.
When to Use: First-time queue setup or adding queues to existing Worker project.