RobotEyes
RobotEyes

Reputation: 5250

How to stop binding to AMQP default exchange?

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" command:

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

Upvotes: 4

Views: 5503

Answers (1)

jimr
jimr

Reputation: 11230

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.

Upvotes: 5

Related Questions