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
1 Answer
Reset to default 5RabbitMQ 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条)