kafka消费端一直报这个错误:
o.s.k.listener.LoggingErrorHandler - Error while processing: null
o.s.k.listener.LoggingErrorHandler - Error while processing: null
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.
at org.apache.kafka.clients.consumer.internals.ConsumerCoordinator.sendOffsetCommitRequest(ConsumerCoordinator.java:722)
at org.apache.kafka.clients.consumer.internals.ConsumerCoordinator.commitOffsetsSync(ConsumerCoordinator.java:600)
at org.apache.kafka.clients.consumer.KafkaConsumer.commitSync(KafkaConsumer.java:1250)
at brave.kafka.clients.TracingConsumer.commitSync(TracingConsumer.java:146)
at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.commitIfNecessary(KafkaMessageListenerContainer.java:1327)
at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.processCommits(KafkaMessageListenerContainer.java:1188)
at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.run(KafkaMessageListenerContainer.java:688)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.lang.Thread.run(Thread.java:745)
转译:
这两个参数的介绍:
max.poll.interval.ms
max.poll.records
问题原因:
当你提交offset的时候,处理消息已经超过了30秒(默认),消费者已经从成员里踢出来了,重新进行消费者平衡,所以你无法提交。
建议里给了2个方式,通过加大
max.poll.interval.ms
超时时间,默认30秒,或者减少max.poll.records
批次的消息数,少拿点消息,默认500条。以下是java消费者客户端调整时间的例子:
props.put(ConsumerConfig.SESSION_TIMEOUT_MS_CONFIG,60000); props.put(ConsumerConfig.MAX_POLL_INTERVAL_MS_CONFIG,60000); props.put(ConsumerConfig.FETCH_MAX_WAIT_MS_CONFIG,60000); props.put(ConsumerConfig.REQUEST_TIMEOUT_MS_CONFIG,70000);
你的答案