intermediate

Exchange

Route published messages to queues through direct, topic, fanout, or header rules instead of sending producers to queues directly.

In AMQP-style brokers, exchanges route published messages to queues using rules: direct (exact routing key), topic (pattern match), fanout (all bound queues), headers. Producers publish to exchanges, not directly to queues — decoupling routing from producers.

Trade-off: flexible routing versus configuration complexity and harder mental tracing of message paths.

On interviews: design routing for priority orders versus standard orders using topic exchange bindings.

Common pitfalls: orphan bindings; routing key typos silent drop; fanout accidentally duplicating work without idempotent consumers.

Checklist:

  • Diagram exchange type and bindings per use case.
  • Validate routing keys in CI or schema tests.
  • Monitor unroutable message drops.
  • Document binding ownership per team.