Exchanges, queues, routing keys and bindings
coreintermediateRabbitMQ separates "where a message goes" from "who reads it": a producer never publishes directly to a queue, only to an exchange, which routes the message to zero or more bound queues based on a routing key and the exchange's type. A direct exchange routes on an exact key match, fanout broadcasts to every bound queue ignoring the key, and topic matches the key against a wildcard pattern — three genuinely different fan-out shapes from the same core building blocks.
Think of it as
An exchange is a mail sorting office, not a mailbox. A producer drops a letter (message) at the sorting office with a routing label (routing key) — the office doesn't hold letters itself, it uses its sorting rules (the exchange type) and its list of registered addresses (bindings) to decide which actual mailboxes (queues) get a copy.
What we're doing: Show a fanout exchange broadcasting one event to multiple independent consumers.
- 1
- Fanout is the simplest routing rule — no key matching logic, just "everyone bound gets a copy."
- 10
- Each queue is independent from here — three separate consumers, three separate ack/retry lifecycles.
Why this works: This is the classic fanout use case — one event, multiple independent interested parties, none of which should be coupled to each other's processing speed or reliability.
Publishing directly to a queue name instead of through an exchange
Wrong
Better
What you see: A message never reaches its intended consumer despite the producer code appearing to run successfully — because AMQP has no concept of publishing directly to a queue by name; a message published without a valid exchange/routing-key/binding path is silently routed nowhere.
Why: RabbitMQ's core model, inherited from AMQP, always routes through an exchange — this is a structural difference from systems like Kafka where a producer writes to a named topic directly, and treating them as equivalent leads to messages that are published but never delivered.
- Producer — publishes once
- leads to Exchange (publish)
- Exchange — fanout, ignores key
- leads to email-notifications (copy)
- leads to inventory-updates (copy)
- leads to analytics-events (copy)
- email-notifications
- inventory-updates
- analytics-events
The three common exchange types
Remember: A producer publishes to an exchange, never directly to a queue. Direct exchanges match the routing key exactly, fanout ignores the key and broadcasts, topic matches wildcard patterns — bindings connect an exchange to the queues that should receive matching messages.
See also: retries and dead lettering · task queues vs event logs · queue concepts

