当领导者改变时,kafka-node无法重新连接

时间:2016-09-06 12:32:30

标签: node.js apache-kafka

如果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()函数似乎在循环中运行而无法刷新数据。我在这里做错了什么?

0 个答案:

没有答案