This is the problem that I am having
1.If the receiver is started first and then send a message the message is delivered
2 But if the receiver is not started then the code says message sent but starting the receiver does not get the message .
If I try the same sequence in python using pika things seem to work normally .
I also verified that there are no messages using the rabbitmqctl –list_queues command
I am running node.js 0.70 and running on a Ubuntu 11.04 64 bit version
I have the following code in my send.js
var util= require('util')
var amqp = require('amqp');
var connection = amqp.createConnection({host:'localhost',
login:'guest',
password:'guest'});
var pubMessage = function pubM(msg) {
var x = connection.exchange();
var q = connection.queue('helloNode',
{ autoDelete: true, durable: false, exclusive: false }
);
x.publish('helloNode',{helloNode: "This is a message"});
};
connection.addListener('ready', pubMessage);
console.log(" Sent a message ");
and the following code in my receiver
var util= require('util')
var amqp = require('amqp');
var connection = amqp.createConnection({host:'localhost',
login:'guest',
password:'guest'});
connection.on('ready', function () {
var q = connection.queue('helloNode',
{ autoDelete: true, durable: false, exclusive: false }
);
q.bind('#');
q.subscribe(function (message) {
util.p(message);
});
});
Your queue binding is being set with autoDelete: true. With this set, if the receiver isn’t connected (or when it disconnects) then there is no queue to route messages to. Setting autoDelete: false leaves the queue intact even if the receiver goes offline and will continue accruing messages.