如果kafka领导人改变
,我收到以下错误BrokerNotAvailableError:找不到领导者
正如kafka-node故障排除所示 - faq我在client.on中使用了client.refreshMetadata()(" close")。
client.on('close', function (err) {
producer.close();
if ( reconnectInterval == null) {
reconnectInterval =
setInterval(function () {
log.info("Reconnect is called on client close");
client = DBConnection.getConnection('kafka');
client.refreshMetadata(["topic1", "topic2"], function (data) {
Producer = kafka.HighLevelProducer;
producer = new Producer(client);
});
}, timeToRetryConnection);
}
}
但是refreshMetadata()函数似乎在循环中运行而无法刷新数据。我在这里做错了什么?