欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 文旅 > 美景 > org.apache.kafka.clients.consumer.CommitFailedException

org.apache.kafka.clients.consumer.CommitFailedException

2024/10/24 4:42:02 来源:https://blog.csdn.net/htydowd/article/details/139354834  浏览:    关键词:org.apache.kafka.clients.consumer.CommitFailedException

kafka报org.apache.kafka.clients.consumer.CommitFailedException问题分析

org.apache.kafka.clients.consumer.CommitFailedException: Commit cannot be completed since the group has already rebalanced and assigned the partitions to another member. This means that the time between subsequent calls to poll() was longer than the configured max.poll.interval.ms, which typically implies that the poll loop is spending too much time message processing. You can address this either by increasing max.poll.interval.ms or by reducing the maximum size of batches returned in poll() with max.poll.records.

这个报错信息说的非常的清楚:

1. commit提交失败,因为已经重新平衡并把分区分给了别人

2. 失败原因是 两次 poll 方法间隔时间 超过了 max.poll.interval.ms 设置的时间

3. 解决方案 是 增加 max.poll.interval.ms 设置的时间 或者 减少 max.poll.records 设置的数量

如果报这种错误,会有什么结果:

如果消费者A 处理数据 超时,kafka 会将 A 消费者消费的数据分区 重新分配给另一个消费者B 并且 消费者B 会 重新消费 A 没有 提交的数据。 这种情况 数据 会重复处理。并且当A 恢复在线时,Kafka 会 再次重新分配分区

调整 max.poll.interval.ms 或者 max.poll.records 能够解决,但是依然避免不了这种问题。最好的解决方案 就是 优化 消费的处理逻辑。

这种情况是 处理逻辑超时,但是 程序最终会执行commit。

如果 处理的时候抛了异常 没有执行 commit 会怎样?

当然,数据也不会丢,会被其他消费者消费。

再消费数据时,需要考虑 重复消费的问题。上面两种情况,数据都不会丢,但有可能被重复处理。

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com