CodePark/ questions / RabbitMQ: exchanges, queues & routing
START PRACTICINGPRACTICE
Backend question · Message queues & streaming › RabbitMQ: exchanges, queues & routing

A service publishes to a direct exchange using a routing key that no queue is bound to. No special flags or policies are set. What happens to the message?

It is silently dropped

The message is silently dropped. Exchanges do not store messages, so the broker discards a message that matches no queue.

So "The broker keeps it in the exchange until a matching queue is bound" is wrong. "The publish call throws an error in the client" is also wrong. A plain publish never throws for this, because publishing is asynchronous.


To detect unroutable messages:

• Publish with the
mandatory flag. The broker then returns the message to the publisher.
• Or configure an
alternate exchange. It catches messages that no queue matches.