Search code examples
phpjavascriptnode.jsrabbitmqamqp

RabbitMQ: What does the 'direct' heading under `rabbitmqctl list_exchanges` mean?


If I create an exchange in rabbitmq using php's amqp class with exchange type set to direct and the only option specified is durable, then try to connect to that exchange in node.js, I get a Cannot redeclare exchange with different options error you see if you're options don't match.

However, as far as i can tell, i am using the exact same options (type direct, and option durable). So i did a test and created one exchange in php called php_exchange and one in node.js called node_exchange and ran rabbitmqctl list_exchanges and got some interesting output:

Listing exchanges ...
node_exchange   direct
amq.headers headers
amq.direct  direct
amq.match   headers
amq.fanout  fanout
    direct
php_exchange    direct
amq.topic   topic
...done.

What does the direct heading mean in this context (clearly it's not all exchanges of type direct, as it lists node_exchange as being of type direct)? How can i get node.js to create an identical amqp exchange (so that it won't fail when connecting to a durable exchange)?

I am using the PECL php amqp library and the node-amqp library (https://github.com/ry/node-amqp)

Thanks.

EDIT:

Here is the output of rabbitmqctl list_exchanges name type auto_delete internal arguments (with the other exchanges removed for brevity):

Listing exchanges ...
node_exchange   direct  false   false   []
php_exchange    direct  false   false   []
...done.

Solution

  • That's not a heading - it's a consequence of a slightly confusing aspect of AMQP, which is that there's a direct exchange called "". This is the "default" exchange, to which all queues automatically get bound.

    In terms of your problem with PECL vs node-amqp, I don't use either of those, but maybe your exchanges differ in something other than type or durability. "rabbitmqctl list_exchanges name type auto_delete internal arguments" will add more columns to the table returned to show all the details of your exchanges. Or look at the management plugin.