栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

kafka常见问题处理

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

kafka常见问题处理

消费消息超时,导致重复消费问题,消息堆积

报错日志示例

org.springframework.kafka.KafkaListenerEndpointContainer#2-0-C-1 org.apache.kafka.clients.consumer.internals.ConsumerCoordinator.maybeAutoCommitOffsetsSync:648 - Auto-commit of offsets {gate_contact_modify-0=OffsetAndmetadata{offset=2801, metadata=''}} failed for group smart-building-consumer-group: 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 the session timeout or by reducing the maximum size of batches returned in poll() with max.poll.records
bug造成的后果

1、重复消费
2、消息堆积,由于offset一直没有提交,导致一直在重复消费同一批次消息,后面的消息没有被消费,造成了消息堆积

问题分析

This means that the time between subsequent calls to poll() was longer than the configured max.poll.interval.ms
这里已经告诉我们消费时间,大于max.poll.interval.ms(默认300秒(5分钟))
既然知道是消费时,大于了这个时间,那就好解决了,我们可以看下每条消息处理耗时。

解决方案

1、减少每批次拉去数据量,即修改max.poll.records参数(kafka 0.9以后版本才有)默认拉取记录是500
2、优化每条消息的处理时间,是的改批次消息处理的时间在max.poll.interval.ms内
3、多线程处理拿到的消息数据

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/760781.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号