Fixing retry mechanism when connection to kafka is failed
Change-Id: I091155d375dc20a1534c1473acf348af6d64319d
diff --git a/src/config/config.js b/src/config/config.js
index b533ddb..a73964a 100644
--- a/src/config/config.js
+++ b/src/config/config.js
@@ -30,8 +30,9 @@
let config;
try {
- logger.log('debug', `Loading ${cfgFile}`);
+ logger.log('debug', `Loading ${path.join(__dirname, cfgFile)}`);
config = yaml_config.load(path.join(__dirname, cfgFile));
+ logger.log('debug', `Parsed config: ${JSON.stringify(config)}`);
}
catch(e) {
logger.log('debug', `No ${cfgFile} found, using default params`);
diff --git a/src/controllers/kafka.js b/src/controllers/kafka.js
index 80e64b8..27ddc92 100644
--- a/src/controllers/kafka.js
+++ b/src/controllers/kafka.js
@@ -45,11 +45,15 @@
});
stream.on('error', function (err) {
- logger.log('error', err);
+ logger.log('info', 'Failed to connect to kafka, reconnecting in 5 sec')
+ logger.log('debug', err);
+ setTimeout(connect, 5 * 1000);
});
stream.consumer.on('event.error', function (err) {
- logger.log('error', err);
+ logger.log('info', 'Failed to connect to kafka, reconnecting in 5 sec')
+ logger.log('debug', err);
+ setTimeout(connect, 5 * 1000);
});
stream.on('data', function (msg) {
@@ -82,8 +86,9 @@
});
}
- catch(e) {
- logger.log('warning', 'Failed to connect to kafka, reconnecting in 5 sec', e)
+ catch(err) {
+ logger.log('warning', 'Failed to connect to kafka, reconnecting in 5 sec')
+ logger.log('debug', err);
setTimeout(connect, 5 * 1000);
}
}