Fixing retry mechanism when connection to kafka is failed
Change-Id: I091155d375dc20a1534c1473acf348af6d64319d
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);
}
}