kafka rebalance与数据重复消费问题

在消费Kafka数据时,程序由于enable.auto.commit配置为true导致数据重复消费。问题源于消费者max.poll.interval.ms配置,当消费间隔超过300秒,消费者会被认为失败并触发再平衡。解决方案包括手动提交偏移量、调整提交间隔或优化处理速度。如果消费者组内多消费者,rebalance可能导致JVM运行时错误,建议不同任务使用不同消费者组。
摘要由CSDN通过智能技术生成

问题和现象:

某个程序在消费kafka数据时,总是重复消费相关数据,仿佛在数据消费完毕之后,没有提交相应的偏移量。然而在程序中设置了自动提交:enable.auto.commit为true
检查日志,发现日志提示:

2020-03-26 17:20:21.414  WARN 28800 --- [ntainer#2-0-C-1] o.a.k.c.c.internals.ConsumerCoordinator  : [Consumer clientId=consumer-1, 
groupId=test-consumer-group] Synchronous auto-commit of offsets
 {E2C-GDFS-0=OffsetAndMetadata{offset=9632, leaderEpoch=8, metadata=''}} failed: 
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.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值