Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RabbitMQ and node-amqp: Exchange in confirmed mode does not confirm - why?

I am writing a Node.js application that relies on RabbitMQ. I'm using node-amqp as the library of choice to connect to RabbitMQ.

Once I have established a connection to RabbitMQ, first thing I am going to do is to create an exchange:

var options = { autoDelete: false, confirm: true, durable: true, type: 'direct' };
connection.exchange('myExchange', options, function (myExchange) {
  // ...
});

This works perfectly. As you can see, I am creating the exchange using confirm: true, hence I expect the exchange to be in confirm mode afterwards.

Now a problem appears once I try to publish a message:

var options = {};
myExchange.publish('', { data: 'foobar' }, options, function () {
  // ...
});

The problem is that the callback of the publish function is never called - although the message was successfully published (as I can see within RabbitMQ's web management tool).

Did I understand confirm mode in a wrong way? Is this a bug with node-amqp?

Any help would be appreciated :-)

like image 1000
Golo Roden Avatar asked Sep 30 '12 15:09

Golo Roden


People also ask

What is delivery mode in RabbitMQ?

When a consumer (subscription) is registered, messages will be delivered (pushed) by RabbitMQ using the basic. deliver method. The method carries a delivery tag, which uniquely identifies the delivery on a channel. Delivery tags are therefore scoped per channel.

What is ACK in RabbitMQ?

Acknowledgements (Consumer Acknowledgements, Ack, Delivery Acknowledgements) When RabbitMQ delivers a message to a consumer, it needs to know when to consider the message successfully sent. An ack will acknowledge one or more messages, which tells RabbitMQ that a message/messages has been handled.

How do I publish a message in RabbitMQ?

Publishing single messages to a RabbitMQ queue can be easily done with the UI, by simply putting the message in the UI and clicking the "Publish Message" button.

How do you Requeue Unacked messages in RabbitMQ?

To reject messages in bulk, clients set the multiple flag of the basic. nack method to true . The broker will then reject all unacknowledged, delivered messages up to and including the message specified in the delivery_tag field of the basic. nack method.


1 Answers

Question answered in the appropriate GitHub issue: node-amqp on npm is an old version ... current workaround is to use the master branch from GitHub directly.

This means, use https://github.com/postwait/node-amqp/tarball/master when installing using npm.


Update November 2013

As I was using RabbitMQ again these days (about one year after my original question), I thought it might be a good idea to give an update on the status quo of node-amqp.

Unfortunately the state of node-amqp is exactly the same as a year ago: The published version from npm is hardly usable. Some of the bugs I encountered a year ago are still there (including the one from my question), so the given workaround is still valid: Get the latest master from GitHub.

like image 123
Golo Roden Avatar answered Oct 22 '22 03:10

Golo Roden