javascript – 如何停止绑定到AMQP默认交换?

每次我将AMQP队列绑定到交换机时,它自动似乎绑定到“默认”直接交换.

这是使用rabbitMQ服务器和node.js的代码:

var amqp = require('amqp');

var connection = amqp.createConnection({host:'localhost'});

connection.on('ready', function(){
    var q = connection.queue('test_queue_name');
    var exc = connection.exchange('test_exchange', { autoDelete:true });
    q.bind('test_exchange', 'test.key');
});

这是使用“rabbitmqctl list_bindings”命令时的控制台输出:

Listing bindings ...
        exchange        test_queue_name queue   test_queue_name []
test_exchange   exchange        test_queue_name queue   test.key        []
...done.

解决方法:

RabbitMQ使用与队列名称相同的路由密钥自动将每个队列绑定到默认交换.

docs

The default exchange is a direct exchange with no name (empty string) pre-declared by the broker. It has one special property that makes it very useful for simple applications: every queue that is created is automatically bound to it with a routing key which is the same as the queue name.

我很确定这是AMQP规范的一部分.

上一篇:rabbitmq生产者的消息确认


下一篇:单机部署RabbltMQ环境的操作记录