我有一个关于 sarama Go 语言 Kafka 库的看似简单的问题:当 Kafka 代理由于空闲超时(由connections.max.idle.ms
配置控制)而关闭时,生产者是否应该在/通过发送新消息时自动重新建立与代理的连接消息与否?
我无法在我检查的任何资源中找到答案:
我问是因为它似乎没有自动重新连接 - 现在我应该尝试避免超时(通过增加connections.max.idle.ms
配置或发送心跳消息)还是应该提出 sarama 的问题?
我还查看了 sarama 日志以获取有关此处实际发生的情况的线索(测试场景,每 10 分钟发送一次消息)但是,对于 Kafka 和 Go 来说都是新手,我无法从中获得太多收益:
...
2021/02/03 07:55:46 producer/broker/0 starting up
2021/02/03 07:55:46 producer/broker/0 state change to [open] on <topic>/0
2021/02/03 07:55:46 Connected to broker at <hostIP>:30001 (registered as #0)
2021/02/03 08:05:46 client/metadata fetching metadata for all topics from broker <host>:30001
2021/02/03 08:06:46 producer/broker/0 state change to [closing] because EOF
2021/02/03 08:06:46 Closed connection to broker <hostIP>:30001
2021/02/03 08:06:46 producer/leader/<topic>/0 state change to [retrying-1]
2021/02/03 08:06:46 producer/leader/<topic>/0 abandoning broker 0
2021/02/03 08:06:46 producer/broker/0 input chan closed
2021/02/03 08:06:46 producer/broker/0 shut down
2021/02/03 08:07:01 Producer shutting down.
2021/02/03 08:15:46 client/metadata fetching metadata for all topics from broker <host>:30001
2021/02/03 08:25:46 client/metadata fetching metadata for all topics from broker <host>:30001
...