KafkaConsumer.commitSync(Map<TopicPartition, OffsetAndMetadata> offsets)
可以使用上述方法来提交未分配的TopicPartition的偏移量吗?
我知道ConsumerRebalanceListener.onPartitionsRevoked
是在TopicPartition重新平衡之前进行最终偏移提交的正确位置。
但是如果我提交一个分区的偏移量,该分区现在消费者在其分配的列表中没有,例如重新平衡后丢失了,卡夫卡将如何对待?
答案 0 :(得分:1)
它将引发以下异常:
Exception in thread "main" org.apache.kafka.clients.consumer.CommitFailedException: Offset commit cannot be completed since the consumer is not part of an active group for auto partition assignment; it is likely that the consumer was kicked out of the group.
at org.apache.kafka.clients.consumer.internals.ConsumerCoordinator.sendOffsetCommitRequest(ConsumerCoordinator.java:1109)
at org.apache.kafka.clients.consumer.internals.ConsumerCoordinator.commitOffsetsSync(ConsumerCoordinator.java:976)
at org.apache.kafka.clients.consumer.KafkaConsumer.commitSync(KafkaConsumer.java:1511)
at org.apache.kafka.clients.consumer.KafkaConsumer.commitSync(KafkaConsumer.java:1459)