Skip to main content
InterviewHubPRO
Section Overview
Q4

Question 4 of 50

Part 1: Basic & Foundational Concepts (Junior / Entry-Level)

8%
RabbitMQ & AMQP (50 Qs)•Part 1: Basic & Foundational Concepts (Junior / Entry-Level)

Compare RabbitMQ Exchange Types: Direct vs. Fanout vs. Topic vs. Headers.

junior LevelRabbitMQMicroservices

In Simple Words:

  1. Direct Exchange (amq.direct):
    • Routes messages strictly where Routing Key == Binding Key.
    • Example: A message with routing key error goes only to the queue bound with error.
  2. Fanout Exchange (amq.fanout):
    • Ignores routing keys completely. Clones and broadcasts incoming messages to every queue bound to it.
    • Example: Publish-subscribe broadcast (e.g., updating user status across chat, notification, and analytics services).
  3. Topic Exchange (amq.topic):
    • Routes based on wildcard pattern matching of dot-delimited words:
      • * (star) matches exactly one word (order.*.created matches order.usa.created, but not order.usa.ny.created).
      • # (hash) matches zero or more words (order.# matches order.usa, order.usa.ny.created, and order).
  4. Headers Exchange (amq.headers):
    • Routes messages based on arbitrary key-value pairs in message headers instead of the routing key. Can require all headers to match (x-match: all) or any header (x-match: any).