In RabbitMQ, a direct exchange routes messages based on which of the following?
Think about how direct exchanges use routing keys to deliver messages.
A direct exchange delivers messages to queues where the routing key exactly matches the queue's binding key. This allows precise routing.
Given the RabbitMQ command below, what is the expected result?
rabbitmqadmin declare binding source=direct_logs destination=my_queue routing_key=error
Consider what binding with a routing key does in a direct exchange.
Binding a queue with a routing key means the queue receives messages from the exchange only if the message's routing key matches the binding key.
Arrange the following steps in the correct order to set up a direct exchange named 'logs', a queue named 'error_logs', and bind them with routing key 'error'.
Think about what must exist before binding and publishing.
You must first declare the exchange, then the queue, then bind them before publishing messages.
You have a direct exchange 'logs' and a queue 'info_logs' bound with routing key 'info'. You publish a message with routing key 'warning' but 'info_logs' does not receive it. Why?
Recall how direct exchanges route messages based on routing keys.
Direct exchanges deliver messages only to queues with matching binding keys. Since 'warning' ≠ 'info', the queue does not get the message.
When using a direct exchange in RabbitMQ, which practice best ensures that messages are not lost if the consumer is temporarily offline?
Think about how RabbitMQ handles message durability and persistence.
Declaring queues as durable and publishing persistent messages ensures messages survive broker restarts and are stored until consumed.