5. Common Use Cases for RabbitMQ
❖ Application Decoupling
❖ Reliable (stored-and-forwarded)
❖ Offload Your Data Store
❖ Scalability
❖ Resilience
❖ Asynchronous Communication
❖ Real-time applications
Resilience /rɪˈzɪl.jənt/
6. RabbitMQ Architecture
Producer: Application that sends the messages
Consumer: Application that receives messages
Exchange: A message routing agent
Queue: Buffer that stores messages.
Binding - A binding is a link between a queue
and an exchange
Routing key: The routing key is a key that the
exchange looks at to decide how to route the
message to queues. The routing key is like an
address for the message
Producer /prə´dju:sə/ (n); Consumer /kən'sju:mə/ (n); Broker /'broukə/ (n)
7. AMQP Protocol
❖ AMQP (Advanced Message Queuing Protocol) is the protocol used by RabbitMQ for messaging
❖ Network wire-level protocol
❖ The structure of an AMQP message:
8. Exchange
❖ Direct Exchange
❖ Topic Exchange
❖ Fanout Exchange
❖ Headers Exchange
❖ Default exchange
❖ Dead Letter Exchange
9. Direct Exchange
❖ The default exchange AMQP brokers must
provide for the direct exchange is "amq.direct"
❖ It’s always created in each Virtual Host
❖ Uses string as routing key
❖ The binding key must match the routing key
exactly - no wildcard support.
❖ Example:
➢ Queue binds to exchange with key K1
➢ Publisher sends message with key K2
➢ Message is passed to this queue if K1=K2
10. Topic Exchange
❖ The default exchange AMQP brokers must
provide for the direct exchange is "amq.topic"
❖ It’s always created in each Virtual Host
❖ Same as Direct Exchange, but wildcards are
allowed in the binding key. '#' matches zero or
more dot-delimited words and '*' matches
exactly one such word.
11. Fanout Exchange
❖ The default exchange AMQP brokers must
provide for the direct exchange is "amq.fanout"
❖ It’s always created in each Virtual Host
❖ No routing key
❖ No binding key
❖ All published messages go to all bound queues
12. Headers Exchange
❖ The default exchange AMQP brokers must
provide for the direct exchange is
"amq.headers"
❖ It’s always created in each Virtual Host
❖ Same as Topic Exchange, use the message
header attributes for routing
13. Default Exchange
The default exchange is a pre-declared direct exchange with no name,
usually referred by the empty string "". When you use the default exchange,
your message will be delivered to the queue with a name equal to the routing
key of the message. Every queue is automatically bound to the default
exchange with a routing key which is the same as the queue name.
14. Dead Letter Exchange
If no matching queue can be found for the message, the message will be
silently dropped. RabbitMQ provides an AMQP extension known as the "Dead
Letter Exchange" - the dead letter exchange provides functionality to capture
messages that are not deliverable.