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$OffsetCommitResponseHandler.handle(ConsumerCoordinator.java:775) at org.apache.kafka.clients.consumer.internals.ConsumerCoordinator$OffsetCommitResponseHandler.handle(ConsumerCoordinator.java:726)
工作中遇到的kafka異常和解決辦法 記錄一下
原文地址https://blog.csdn.net/shibuwodai_/article/details/80678717
異常
異常的主要信息:
a) CommitFailedException
b) 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.
其實如果我們對其中的參數,或是對消費的機制比較了解,這個問題就很好解決。當我看到這個異常,我很開心,因為我知道我能通過此異常了解一下Kafka Consumer 消費消息的大致過程。心態是好的~~~
其實現在看這個異常是說:該Consumer不能提交offset了,因為它已經出局了,是因為你的處理小時時間長於你要報告給server的時間。同時還告訴我們怎么處理:要么增加超時時間,要么減少每次poll回來的消息個數。
主要問題在於,何為session timeout?maximum size of batches?poll(timeout)中timeout什么意思?
處理過程
a) 找官網doc
版本:1.1.0
有效信息:
換成通俗易懂的人話:
下邊這個例子如果理解不上,請通讀全文后,再回來理解一下筆者的意思
------------------------------------分割線------------------------------------
------------------------------------分割線------------------------------------
通過上邊的例子,我們大致清楚了max.poll.interval.ms?maximum size of batches?
max.poll.interval.ms:消費者最大心跳時間間隔
maximum size of batches:消費者每次獲取消息的個數
什么時候發送心跳呢?是poll()方法被調用發送心跳嗎?那poll(timeout)中timeout是什么意思呢?
官網對poll(timeout)中timeout的解釋如下:
-
Parameters:
-
timeout - The time, in milliseconds, spent waiting in poll if data is not available in the buffer. If 0,returns immediately with any records that are available currently in the buffer,else returns empty. Must not be negative.
這個我費了很大力氣都沒有給它翻譯成人話……