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

标签 java apache-kafka kafka-consumer-api

当 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/

相关文章:

Java奇怪的方法

mysql - Flink1.5中如何将kafkaJson数据放入外部MySQL数据库

java - 如何在kafka springboot中从一个主题读取多种类型的json

spring-boot - 如何使用多个ack在同一主题上消费多个kafka消息?

apache-kafka - 如何配置Apache Kafka在指定时间发送数据?

java - 如何获取 vtd-xml 中的父元素?

java - 寻找最大面积的算法

apache-kafka - Kafka 服务器节点出现 “Too many open files” 错误

apache-kafka - WAN 上的 Kafka 生产者/消费者?

Java 反射和泛型 - 参数化类型信息丢失 "extends"