Is it possible to create a user without defining a RabbitMQ exchange?

There is code in the runtime creates a consumer of messages from a queue, rmq (taken from example `sping-rabbitmq`).

Question: is it possible to get rid of the definition of exchange? And if so, how? Exchange because needed only for the delivery of messages to the queue, and consumers like nothing to do here...

CachingConnectionFactory cf = new CachingConnectionFactory("localhost");

RabbitAdmin admin = new RabbitAdmin(cf);
Queue queue = new Queue(queueName);
TopicExchange exchange = new TopicExchange("myExchange");

SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(cf);
Object listener = new Object() {
 public void handleMessage(byte[] message) { ... }
MessageListenerAdapter adapter = new MessageListenerAdapter(listener);
July 9th 19 at 10:23
2 answers
July 9th 19 at 10:25
workarou put in a router and not worried
July 9th 19 at 10:27
Java not writing, but: have You tried to remove those three lines where you use exchange? This causes the error?

The problem is that the queue and the exchanger will need to bind (create binding), this can be done when the queue is created or when you create an exchanger, or, in a third time. If this is not done, the messages published in the exchanger do not fall in line.
But if you want just turn, without any real need for the exchanger, then when you publish you can use the exchange default (empty string) and the queue name as routing key, and RabbitMQ will throw a message into this queue.

Find more questions by tags JavaRabbitMQ