如何知道在java kafka应用程序客户端中是否达到max.poll.interval.ms?
How to know if max.poll.interval.ms is reached in java kafka application client?
当达到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()
直到re-balancing完成你的consumer重新进入consumer group
当达到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 aCommitFailedException
thrown from a call tocommitSync()
). 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()
直到re-balancing完成你的consumer重新进入consumer group