Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-6470

no continuous offset for function seek

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 0.10.0.1
    • None
    • clients, core
    • None

    Description

      A topic-partition "adn-tracking,15"  in kafka  who's   earliest offset is  1255644602 and  latest offset is 1271253441.  

      while starting a spark streaming to process the data from the topic ,  we got a exception with "Got wrong record XXXX  even after seeking to offset 1266921577".

      I  implemented a simple project to use consumer to  seek offset 1266921577. But it return the offset 1266921578. Then while  seek to 1266921576, it return the 1266921576 exactly。 

      Why ?  How to fix that ?

       

       

      There is the code:

      public class consumerDemo {

      public static void main(String[] argv)

      {   Properties props = new Properties(); props.put("bootstrap.servers", "172.31.29.31:9091"); props.put("group.id", "consumer-tutorial-demo"); props.put("key.deserializer", StringDeserializer.class.getName()); props.put("value.deserializer", StringDeserializer.class.getName()); KafkaConsumer<String, String> consumer = new KafkaConsumer<String, String>(props); TopicPartition tp = new TopicPartition("adn-tracking-click", 15); Collection<TopicPartition> collection = new ArrayList<TopicPartition>(); collection.add(tp); consumer.assign(collection); consumer.seek(tp, 1266921576); ConsumerRecords<String, String> consumerRecords = consumer.poll(10000); List<ConsumerRecord<String, String>> listR = consumerRecords.records(tp); Iterator<ConsumerRecord<String, String> > iter = listR.iterator(); ConsumerRecord<String, String> record = iter.next(); System.out.println(" the next record " + record.offset() + " recode topic " + record.topic()); }

      }

       

       

       

          

      Attachments

        Activity

          People

            Unassigned Unassigned
            chao.wu chao.wu
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: