Skip to main content...
Redis + Messaging
20 min

Day 95: RabbitMQ: exchanges and routing

RabbitMQ: exchanges decide where a message goes

In RabbitMQ, a publisher never sends directly to a queue — it sends to an exchange, which routes the message to one or more bound queues based on the exchange type and a routing key.

  • Direct exchange — routes to queues whose binding key exactly matches the message's routing key
  • Fanout exchange — broadcasts to every bound queue, ignoring the routing key entirely
  • Topic exchange — matches routing keys against wildcard patterns (e.g. "orders.*.created")
A topic exchange example
Routing key: orders.eu.created
Binding pattern: orders.*.created   -> matches
Binding pattern: orders.eu.#         -> matches
Binding pattern: orders.us.created  -> does NOT match

Why this indirection matters

Because publishers only know about the exchange, not the queues, you can add a new consumer (a new queue bound to the same exchange) without touching any publisher code — a real decoupling benefit, directly analogous to how a Kubernetes Service (Phase 9) decouples callers from specific Pod IPs.

Key terms

Exchange
Receives published messages and routes them to bound queues based on type and routing key.
Topic exchange
Routes messages using wildcard pattern matching against routing keys.

You need every subscribed service to receive a copy of every "user signed up" event, regardless of any routing key. Which exchange type fits?

We use cookies

We use cookies to enhance your browsing experience, serve personalized content, and analyze our traffic. By clicking "Accept All", you consent to our use of cookies. Learn more

    Day 95: RabbitMQ: exchanges and routing | RBTechIconX