node.js - How to exit from a node-kafka consumer if no message received within pre-defind time -


i have written node-kafka consumer. works absolutely fine if there message available in topic gets blocked forever if there no new message available in topic. want close consumer , call callback function if no message received within time-frame. there way handle scenario.

below code snippet consumer:

consumer = new kafka.highlevelconsumer( client, [ { topic: topic, partition: 0, fromoffset: false, fetchmaxwaitms: 100} ], { autocommit: false } ); consumer.on('message', function (message) { console.log("received message", message); returnarray.push(message.value); if(message.offset == (message.highwateroffset -1)){ consumer.close(true, function(err, message) { console.log("consumer has been closed.."); });

      callback(returnarray);     }  

thanks, ankit


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -