Your issue here is really around the low knowledge of AMQP. You should understand what is Exchange
, routingKey
and Binding
.
You need to configure:
<rabbit:direct-exchange name="myExchange">
<rabbit:bindings>
<rabbit:binding queue="userMesssageQueue" key="userMesssage" />
</rabbit:bindings>
</rabbit:direct-exchange>
From other side you should send message to concrete exchange
using concrete routingKey
. In your case:
template.send("myExchange", "userMesssage", message);
Only in this case your message will be placed to the userMesssageQueue
.
By default RabbitTemplate
uses empty string for exchange
(the Default one) and empty string for routingKey
. Since your userMesssageQueue
isn't bound to that exchange with that routing key, your listener doesn't receive it.
The sending works without errors, because messages are placed to the exchanges and it is enough for Producer (sender).
In the end your message is just dropped on the RabbitMQ broker, because there is no queues bound to the ""
routing key.
Please, read more docs on the RabbitMQ site and Spring AMQP.