views:

146

answers:

1

I'm trying to publish messages to RabbitMQ, from a Ruby script (using Bunny) and consume them from a node.js server (using node-amqp).

The first message arrives successfully, but then an error is logged inside node.js, and the connection closes, and no further messages are received:

mu:charlie-node tom$ node charlie.js 
22 Jul 09:11:04 - Running in development environment.
22 Jul 09:11:04 - Connected to AMQP.
22 Jul 09:11:04 - {"build_id":1234}
Unhandled channel error: NOT_FOUND - unknown delivery tag 1

If I publish two messages into the exchange, and then run the node.js server I can see both of them arrive before the error is logged, which suggests to me that RabbitMQ is closing the exchange or queue when it's empty. However, since I've got autoDelete set to false on both of those it shouldn't.

Any suggestions?

My node.js script looks something like this:

var amqpConnection = amqp.createConnection({ host: config.rabbitmq.host });

amqpConnection.addListener('ready', function() {
  sys.log("Connected to AMQP.");

  var exchange = amqpConnection.exchange('job_exchange', {
    type : 'topic',
    passive : false,
    durable : true, 
    autoDelete : false
  })

  exchange.addListener('open', function() {

    var queue = amqpConnection.queue('arthr_queue', {
      passive : false,
      autoDelete : false,
      durable : true,
      exclusive : false
    });

    queue.bind(exchange, '#');

    queue.subscribe(function(message) {
      sys.log(message.data.toString());
    });
  });
});

And my Ruby script looks like:

require 'rubygems'
require 'bunny'
require 'json'

b = Bunny.new(:logging => true)

b.start

job_exchange = b.exchange('job_exchange', 
  :type => :topic, 
  :durable => true, 
  :auto_delete => false, 
  :passive => false
)

message = {
  :build_id => 1234
}

job_exchange.publish(message.to_json, :key => 'arthr.rebuild')

b.stop
+1  A: 

I think this is a bug in node-amqp. The code sends an ack by default when options.ack is set to false.

The amqp 0.8 specifications say that the server does it on the clients behalf when noAck.

I witnessed the bug with RabbitMQ 1.8.1. Maybe they got stricter.

It is fixed in my branch (http://github.com/spahl/node-amqp) and all the tests pass. I also fixed the fact that it tries to redeclare the default 'amq.topic' exchange as non durable.

Seb
Perfect - that fixes it for me. Thanks!
tomtaylor