javascript - How to stop binding to AMQP default exchange? - Stack Overflow

Every time I bind an AMQP queue to an exchange it automatically seems to bind to the 'default'

Every time I bind an AMQP queue to an exchange it automatically seems to bind to the 'default' direct exchange.

Here's the code in using a rabbitMQ server and 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');
});

Here's the console output when using the "rabbitmqctl list_bindings" mand:

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

Every time I bind an AMQP queue to an exchange it automatically seems to bind to the 'default' direct exchange.

Here's the code in using a rabbitMQ server and 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');
});

Here's the console output when using the "rabbitmqctl list_bindings" mand:

Listing bindings ...
        exchange        test_queue_name queue   test_queue_name []
test_exchange   exchange        test_queue_name queue   test.key        []
...done.
Share Improve this question asked Jun 16, 2012 at 23:54 RobotEyesRobotEyes 5,2508 gold badges47 silver badges61 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

RabbitMQ automatically binds every queue to the default exchange with a routing key the same as the queue name.

From the 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.

I'm pretty sure this is part of the AMQP spec.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745285779a4620550.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信