我有一个 Java 消费者应用程序,它连接到名为“my_exhange_foo”的 RabbitMQ (3.2.4) 不可删除扇出交换:
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);
无论是否声明了交换,客户端消费者应用程序都会接收消息。
我按照本教程中的示例 ReceiveLogsDirect.java https://www.rabbitmq.com/tutorials/tutorial-four-java.html
并阅读api但无法弄清楚在消费者方面声明交换的目的是什么。如果有人能对此有所了解,我将不胜感激。