diff --git a/package.json b/package.json index 1550898..16d93bf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "quintoandar-kafka", - "version": "0.0.8", + "version": "0.0.9", "description": "Default Kafka NodeJS lib for QuintoAndar", "main": "src/main.js", "dependencies": { diff --git a/src/node-kafka-consumer.js b/src/node-kafka-consumer.js index 895f222..ab842bc 100644 --- a/src/node-kafka-consumer.js +++ b/src/node-kafka-consumer.js @@ -15,6 +15,7 @@ class KafkaConsumer { _.defaults(this.configs, { fromOffset: 'latest' }); _.defaults(this.configs, { outOfRangeOffset: 'latest' }); _.defaults(this.configs, { fetchMaxBytes: 1024 * 1024 }); + _.defaults(this.configs, { updateMetadata: 90 * 1000 }); } validateConfigs() { @@ -44,7 +45,7 @@ class KafkaConsumer { this.consumer.commit(msg, true); }); }); - setInterval(this.refreshMetadata.bind(this), this.sessionTimeout + 30000); + setInterval(this.refreshMetadata.bind(this), this.updateMetadata); logger.info('ConsumerGroupStream started'); } diff --git a/tests/node-kafka-consumer.test.js b/tests/node-kafka-consumer.test.js index d26506d..93ed5ab 100644 --- a/tests/node-kafka-consumer.test.js +++ b/tests/node-kafka-consumer.test.js @@ -68,7 +68,8 @@ describe('Kafka Consumer', () => { asyncPush: false, fromOffset: 'latest', outOfRangeOffset: 'latest', - fetchMaxBytes: 1024 * 1024 + fetchMaxBytes: 1024 * 1024, + updateMetadata: 90000 }; const topics = ['Test'];