新版kafka消费者配置问题

struggle 发表于: 2017-07-09   最后更新时间: 2021-09-24 16:08:44   7,981 游览

1、新版kafka配置,好像没看到有介绍啊?

2、我的消费者总是出现这个提示,不知是不是正常的,提示如下:

Auto offset commit failed for group baiying-visualize: 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.

我的部分代码和相关配置如下:

ConsumerRecords<String, String> records = consumer.poll(100);

properties配置文件中部分配置如下:

enable.auto.commit=true
auto.commit.interval.ms=1000
key.deserializer=org.apache.kafka.common.serialization.StringDeserializer
value.deserializer=org.apache.kafka.common.serialization.StringDeserializer
max.poll.interval.ms=500 
max.poll.records=50
session.timeout.ms=30000
发表于 2017-07-09
添加评论

配置在这里。https://www.orchome.com/535

它说你在提交offset的时候,你已经过了时间(太长时间没有提交offset了,心跳时间过了),发生了再平衡,重新分配了消费者,所有你提交offset失败了。让你增加间隔时间。

更详细的解释,可参见 https://www.orchome.com/6742

struggle -> 半兽人 6年前

ok配置找到了。你说的增加时间间隔是增加max.poll.interval.ms=500这个吗?另外,消费者需要关闭吗,我在网上有看到需要关闭consumer,应该不需要吧

struggle -> 半兽人 6年前

我看了你给的配置连接,max.poll.interval.ms的默认值是300000

半兽人 -> struggle 6年前

max.poll.interval.ms,为何你处理的时间那么长。这个要优化一下。

struggle -> 半兽人 6年前

我把max.poll.interval.ms设成300000,没报这个提示了。

struggle -> 半兽人 6年前

我开始设了500,报这个错,后来我就用默认值了,没有报错。

你的答案

查看kafka相关的其他问题或提一个您自己的问题