CommitFailedException,顾名思义就是Consumer客户端在提交位移时出现错误或异常,还是那种不可恢复的严重异常。
报错:
Caused by: 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 the session timeout or by reducing the maximum size of batches returned in poll() with max.poll.records.
大致意思就是,本次提交位移失败,原因是消费者组开启了Rebalance过程,并且将要提交位移的分区分配给了另一个消费者实例,出现这种情况的原因是,消费者实例连续两次调用poll方法的时间间隔超过了期望的max.poll.interval.ms设置的参数值,就是说消费者实例处理消费花费时间过长,耽误了poll的调用。并给出了两个相应的解决办法:
1、增加两次poll时间间隔max.poll.interval.ms参数值
2、减少poll方法一次性返回的消息数量,即减少max.poll.records参数值