Search code examples
rabbitmqspring-rabbit

Messages lost if queue does not exist


When we send the messages to RabbitMQ and if queue doesn't exist, messages are lost without throwing any error.

Where the messages will be posted to? Dead queue?


Solution

  • That is the way RabbitMQ is designed - publishers publish to exchanges, not queues.

    If there is no queue bound (with a matching routing key if the exchange requires one), the message is simply discarded.

    You can enable publisher returns and set the mandatory flag when publishing and the broker will return the message (but it arrives on a different thread, not the publishing thread).