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