【问题标题】:Can an offset of an unassigned partition be committed by KafkaConsumer.commitSync/commitAsyncKafkaConsumer.commitSync/commitAsync 是否可以提交未分配分区的偏移量
【发布时间】:2020-09-10 11:20:06
【问题描述】:
KafkaConsumer.commitSync(Map<TopicPartition, OffsetAndMetadata> offsets)

上面的方法可以用来提交未分配的TopicPartition的偏移量吗?

我知道ConsumerRebalanceListener.onPartitionsRevoked 是在 TopicPartition 重新平衡之前进行最终偏移提交的正确位置。

但是,如果我现在提交消费者在其分配列表中没有的分区的偏移量,例如rebalance后丢失了,kafka怎么处理?

【问题讨论】:

    标签: java apache-kafka kafka-consumer-api


    【解决方案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)
    

    【讨论】:

      猜你喜欢
      • 2021-02-22
      • 2018-01-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-14
      • 2019-12-09
      相关资源
      最近更新 更多