[rabbitmq-discuss] RECONDITION_FAILED - unknown delivery tag

macmillan.josh09 at gmail.com macmillan.josh09 at gmail.com
Sun May 5 23:48:47 BST 2013


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   


   // index.js
   var amqp = require('amqp');
    
   var connection = null;
    
   connection = amqp.createConnection({ host: 'foo.com' });
    
   connection.on('ready', function () {
     connection.queue('loc', { durable: true, autoDelete: false}, function(q
   ) {
       q.bind('main', 'loc');
       q.subscribe({ack:true, prefetchCount: 0}, function (message, headers,deliveryInfo
   ) {
         console.log(message);
         setTimeout(function() { q.shift(); }, 100);
       });
     });
   });
    
   my worker crashes only I run it AFTER there are messages in the queue. ifI run the worker BEFORE
   , everything is ok.
    
   I use ab to add 2 messages to the queue:
   ab -k -n 2 -c 1 -p post-data -T 'application/json' foo-api.com/publish
    
   And now run my worker - node index.js
   here is the outputs:
    
   { topic: 'loc',
     sourceCode: 'LOC',
     sourceRecordID: '690599224',
     sourceField: 'Phone',
     sourceFieldValue: '7572007395',
     actionCode: 'DISP',
     actionDescription: 'Disconnected Phone Number' 
   }
   { topic: 'loc',
     sourceCode: 'LOC',
     sourceRecordID: '690599224',
     sourceField: 'Phone',
     sourceFieldValue: '7572007395',
     actionCode: 'DISP',
     actionDescription: 'Disconnected Phone Number' 
   }
    
   events.js:72
           throw er; // Unhandled 'error' event
                 ^
   Error: PRECONDITION_FAILED - unknown delivery tag 2
       at Queue._onMethod (/Users/ogolan/projects/quai-loc/worker/
   node_modules/amqp/amqp.js:1979:15)
       at Queue.Channel._onChannelMethod (/Users/ogolan/projects/quai-loc/
   worker/node_modules/amqp/amqp.js:1557:14)
       at Connection._onMethod (/Users/ogolan/projects/quai-loc/worker/
   node_modules/amqp/amqp.js:1088:28)
       at AMQPParser.parser.onMethod (/Users/ogolan/projects/quai-loc/worker
   /node_modules/amqp/amqp.js:897:12)
       at AMQPParser._parseMethodFrame (/Users/ogolan/projects/quai-loc/
   worker/node_modules/amqp/amqp.js:451:10)
       at frameEnd (/Users/ogolan/projects/quai-loc/worker/node_modules/amqp
   /amqp.js:192:16)
       at frame (/Users/ogolan/projects/quai-loc/worker/node_modules/amqp/
   amqp.js:177:14)
       at AMQPParser.header [as parse] (/Users/ogolan/projects/quai-loc/
   worker/node_modules/amqp/amqp.js:163:14)
       at AMQPParser.execute (/Users/ogolan/projects/quai-loc/worker/
   node_modules/amqp/amqp.js:236:21)
       at Connection.<anonymous> (/Users/ogolan/projects/quai-loc/worker/
   node_modules/amqp/amqp.js:935:14)
   



any ideas?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20130505/72dc5e16/attachment.htm>


More information about the rabbitmq-discuss mailing list