node.js - node-amqp and async ack -
i working on project uses rabbitmq. queue have work (lets call "testq" gets time time 35000 items have worked on.
basically (very short):
var q = new queue(); q.subscribe('testq', { ack: true, prefetchcount: 100 }, function(doc, object, queueoptions, originaldocument) { //do action originaldocument.acknowledge(); });
my problem is: want 100 messages @ time (prefetch count = 100), when know 100 messages have been processed can acknowledge , next 100 messages? "do action block" async :(
thanks advice!
you acknowledge messages 1 one , should not worry getting next 100 messages while it's broker job deliver messages you. there nothing wrong have do action
asynchronous, make acknowledge after some action
done, guess can done via callbacks, done in node.js. that:
q.subscribe( 'testq', { ack: true, prefetchcount: 100 }, function(doc, object, queueoptions, originaldocument) { dosomeaction(function() { originaldocument.acknowledge(); }); } );
Comments
Post a Comment