I have a Java consumer application that connects to a RabbitMQ (3.2.4) non-deletable fanout exchange called "my_exhange_foo":
Connection connection = connectionFactory.newConnection(consumerPool);
Channel channel = connection.createChannel();
channel.exchangeDeclare("my_exhange_foo", "fanout"); // is this necessary?
String queueName = channel.queueDeclare().getQueue();
channel.queueBind(queueName, "my_exhange_foo", "");
QueueingConsumer consumer = new QueueingConsumer(channel);
channel.basicConsume(queueName, true, consumer);
The client consumer application receives the messages regardless of whether the exchange is declared or not.
I followed the example ReceiveLogsDirect.java in this tutorial https://www.rabbitmq.com/tutorials/tutorial-four-java.html
and read the api but cannot figure out what the purpose of declaring the exchange is on the consumer side. I would appreciate if someone can shed some light on it.