# Workers Queues: wire both ends

A queue has two config ends that must agree on the queue name.

## Producer: the binding

```toml
[[queues.producers]]
queue = "my-queue"
binding = "MY_QUEUE"
```

Code sends with `env.MY_QUEUE.send(message)`. The `binding` is the JS variable; `queue` is the queue's name.

## Consumer: the entry

```toml
[[queues.consumers]]
queue = "my-queue"
max_batch_size = 10
max_batch_timeout = 30
max_retries = 10
dead_letter_queue = "my-queue-dlq"
```

The consumer Worker implements the queue handler and receives batches. The settings people skip:

- `max_batch_size` / `max_batch_timeout`: tune these together; a large timeout with a small batch size means latency for no throughput gain.
- `max_retries`: after this many failed deliveries the message is dropped or dead-lettered.
- `dead_letter_queue`: without one, poison messages that always fail just burn retries and then vanish. Always set a DLQ in production.

## The failure modes

- Producer and consumer in different Workers referencing different queue names: messages pile up with no consumer, or the consumer idles on an empty queue. One queue name, shared.
- Forgetting the consumer Worker needs the queue handler, not a fetch handler, to process messages.
- Assuming at-least-once delivery means exactly-once: make the consumer idempotent; retries will redeliver.

## Checklist

- Create the queue (`wrangler queues create`) before deploying the consumer.
- Set the DLQ before you need it.
- Check the queue limits page for max values on batch settings before tuning.