Apache kafka 如果偏移量在卡夫卡中损坏会发生什么?

Apache kafka 如果偏移量在卡夫卡中损坏会发生什么?,apache-kafka,kafka-consumer-api,apache-kafka-streams,Apache Kafka,Kafka Consumer Api,Apache Kafka Streams,我们如何处理腐败 我想将偏移日志保存到其他地方,或者拍摄偏移的快照。我该怎么做?卡夫卡将偏移存储在名为“消费者偏移”的主题中。使用者将偏移提交到此主题中,auto.offset.reset(最早/最晚/无)的值决定开始从分区读取消息的策略。偏移日志保留由代理属性指定 auto.offset.reset=latest=>将从上次提交的偏移量开始读取消息,如果未找到,则将等待新消息到达并从那里开始。没有引发异常 auto.offset.reset=earlime=>如果存在偏移量,它将不会再次引发任

我们如何处理腐败


我想将偏移日志保存到其他地方,或者拍摄偏移的快照。我该怎么做?

卡夫卡将偏移存储在名为“消费者偏移”的主题中。使用者将偏移提交到此主题中,auto.offset.reset(最早/最晚/无)的值决定开始从分区读取消息的策略。偏移日志保留由代理属性指定

auto.offset.reset=latest
=>将从上次提交的偏移量开始读取消息,如果未找到,则将等待新消息到达并从那里开始。没有引发异常

auto.offset.reset=earlime
=>如果存在偏移量,它将不会再次引发任何异常,并从一开始就开始读取消息

auto.offset.reset=none
=>当找不到偏移量时,它将引发异常

您可以使用assign and seek获取特定数据

        //assign - set topic and partition you you want to read from using TopicPartion
        TopicPartition topicPartitionToReadFrom = new 
        TopicPartition(topic, 0);
        long offsetToReadFrom = 15L;
        consumer.assign(Arrays.asList(topicPartitionToReadFrom));
        
        //seek - set position of the consumer manually by calling
        //KafkaConsumer.seek(TopicPartition partition, long offset)
        consumer.seek(topicPartitionToReadFrom, offsetToReadFrom);
        

存储偏移日志=>\u消费者偏移是一个主题,因此您可以将邮件存储到您选择的存储中。

这个答案与有关损坏的问题有什么关系?这是您正在经历的一种情况吗?具体来说,您有什么错误?