[rabbitmq-discuss] RECONDITION_FAILED - unknown delivery tag

Calvin French-Owen calvin at segment.io
Tue May 7 20:55:40 BST 2013


We use node-amqp to prefetch multiple messages and then ack them one at a
time. It looks a bit like this:


function subscribe(queue) {
  queue.bind('ingestion', '#');

  var options = { ack : true, prefetchCount : 1000 };

  queue.subscribe(options, function (payload, headers, deliveryInfo, message) {
    importer.log(payload, function (err) {
      try {
        if (err) message.reject(true); // requeue the message
        else message.acknowledge(false); // acknowledge only this message
      } catch (e) {
        logger.error('Error acknowledging queue message', { err : e });
      }
    });
  });
}

Cheers,
-Calvin




On Mon, May 6, 2013 at 2:09 AM, Matthias Radestock <matthias at rabbitmq.com>wrote:

> On 05/05/13 23:48, macmillan.josh09 at gmail.com wrote:
>
>> My Node.js worker crashes (RECONDITION_FAILED - unknown delivery tag) if
>> the following 2 conditions are met:
>>
>> 1. I start it AFTER the queue have at least 2 messages.
>> 2. The q.shift() is in an async code.
>>
>> http://pastebin.com/uMQJn0Fe
>>
>
> Looking at the amqp.js code, q.shift() acknowledges the last message that
> was received. So with your code...
>
>
>           q.subscribe({ack:true, prefetchCount: 0}, function (message,
>>     headers, deliveryInfo) {
>>            console.log(message);
>>            setTimeout(function() { q.shift(); }, 100);
>>     });
>>     });
>>
>
> due to the delayed execution, when two messages arrive in quick succession
> then the first to arrive won't be acknowledged at all and the second will
> be acknowledged twice. Rabbit is complaining about the latter.
>
> I've never used node-amqp, so I don't know what the correct approach is
> for accomplishing what you want to do. You may want to ask the node-amqp
> developers.
>
> Matthias
>
> ______________________________**_________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.**rabbitmq.com<rabbitmq-discuss at lists.rabbitmq.com>
> https://lists.rabbitmq.com/**cgi-bin/mailman/listinfo/**rabbitmq-discuss<https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20130507/19bcd5c7/attachment.htm>


More information about the rabbitmq-discuss mailing list