Reputation: 169
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);
});
});
Upvotes: 2
Views: 3357
Reputation: 26
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.
Upvotes: 1
Reputation: 1
Message is routed to "helloNode" queue and then, when your sender terminates this queue is deleted. This is the case even with "exclusive:false" because there is a subscription to this queue created in your sender. Given this, behavior "if no subscription has been ever active on the queue it will not get auto-deleted" does not apply here.
Maybe pika creates exchanges/queues with different values ?
Upvotes: 0