In RabbitMQ, what is the main role of the exchange in the publish-subscribe pattern?
Think about how messages get from the sender to multiple receivers.
The exchange receives messages from producers and routes them to one or more queues based on binding rules. This allows multiple consumers to receive copies of the message.
What is the output of the following RabbitMQ command when binding a queue named logs to a fanout exchange named broadcast?
rabbitmqadmin declare binding source=broadcast destination=logs
Fanout exchanges do not require a routing key when binding queues.
Binding a queue to a fanout exchange succeeds without a routing key. The command returns a success JSON with source and destination.
Arrange the steps in the correct order to set up a publish-subscribe system using a fanout exchange in RabbitMQ.
Think about declaring resources before using them.
You first declare the exchange, then create queues, bind them to the exchange, and finally publish messages.
You set up a fanout exchange and bound multiple queues to it. However, subscribers connected to these queues do not receive any messages. What is the most likely cause?
Check if the queues are connected to the exchange properly.
If queues are not bound to the exchange, messages published to the exchange have nowhere to go, so subscribers receive nothing.
Which option describes the best practice to ensure messages are not lost in a publish-subscribe system using RabbitMQ fanout exchanges?
Think about how to keep messages safe even if RabbitMQ restarts.
Declaring exchanges and queues as durable and publishing persistent messages ensures messages survive broker restarts and are not lost.