Open saalaa opened 11 years ago
I looked at the tests and this one caught my attention:
https://github.com/postwait/node-amqp/blob/master/test/test-reject.js
I adjusted my code according to it and it's working. This bug is still valid since queue.shift()
is not working as advertised as far as requeue
is concerned.
For the record, here's the adjusted subscriber code:
var amqp = require('amqp');
var mq = amqp.createConnection({host: 'localhost'});
var options = {
autoDelete: false,
durable: true
};
mq.on('ready', function () {
mq.queue('my-queue', options, function (q) {
q.bind('#');
q.subscribe({ack: true}, function (json, headers, info, message) {
console.log(json);
message.reject(true);
});
});
});
Your code in the original issue works perfectly for me. What version of node-amqp are you using? The options to reject and requeue a message using queue.shift
have not been included in the version which has been published to npm yet. I expect that they will be included in 0.1.8.
The queue.shift
code was removed when another pull request was merged in. See this comment.
The title pretty much says it all; in my tests, I was unable to put rejected messages back onto the queue.
Publisher code (don't let it run for too long):
Subscriber code: