KafkaConsumer.commitSync(Map<TopicPartition, OffsetAndMetadata> offsets)
Can above method be used to commit offset of an unassigned TopicPartition ?
I know ConsumerRebalanceListener.onPartitionsRevoked
is the right place to do final offset commit before TopicPartition rebalance.
But if I commit offset of a partition which consumer does not have in its assigned list now, eg it lost it after rebalance, how will Kafka treat it?
It will throw the following Exception:
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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.