gpt4 book ai didi

java - 如何知道在 java kafka 应用程序客户端中是否达到了 max.poll.interval.ms?

转载 作者:行者123 更新时间:2023-12-04 10:14:45 24 4
gpt4 key购买 nike

kafka max.poll.interval.ms时是否有异常抛出达到并发生再平衡?

最佳答案

一旦你的消费者因为长 poll() 而被踢出消费者组,您将收到 CommitFailedException .根据documentation :

It is also possible that the consumer could encounter a "livelock" situation where it is continuing to send heartbeats, but no progress is being made. To prevent the consumer from holding onto its partitions indefinitely in this case, we provide a liveness detection mechanism using the max.poll.interval.ms setting. Basically if you don't call poll at least as frequently as the configured max interval, then the client will proactively leave the group so that another consumer can take over its partitions. When this happens, you may see an offset commit failure (as indicated by a CommitFailedException thrown from a call to commitSync()). This is a safety mechanism which guarantees that only active members of the group are able to commit offsets. So to stay in the group, you must continue to call poll.



因此,您可能会捕获 CommitFailedException .其实你可以继续调用 poll()直到重新平衡完成并且您的消费者重新进入消费者组。

关于java - 如何知道在 java kafka 应用程序客户端中是否达到了 max.poll.interval.ms?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61125555/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com