Did you try setting `auto.offset.reset` to "earliest" ? -Matthias
On 7/18/17 8:44 PM, Yuri da Costa Gouveia wrote: > Hello, > I am having trouble to get the data from old offsets. I'm using the version > 0.10.2.1, and I need any assistance to recover this data. > This is my consumer class: > > String topicName = "test"; > Properties props = new Properties(); > > props.put("bootstrap.servers", "localhost:9092"); > props.put("group.id", "test"); > props.put("enable.auto.commit", "true"); > props.put("auto.commit.interval.ms", "1000"); > props.put("session.timeout.ms", "30000"); > props.put("key.deserializer", StringDeserializer.class.getName()); > props.put("value.deserializer", StringDeserializer.class.getName()); > > Thread.currentThread().setContextClassLoader(null); > KafkaConsumer<String, String> consumer = new KafkaConsumer > <String, String>(props); > > //Kafka Consumer subscribes list of topics here. > consumer.subscribe(Arrays.asList(topicName)); > //print the topic name > System.out.println("Subscribed to topic " + topicName); > int i = 0; > > while (true) { > ConsumerRecords<String, String> records = consumer.poll(100); > for (ConsumerRecord<String, String> record : records) > > // print the offset,key and value for the consumer records. > System.out.printf("offset = %d, key = %s, value = %s\n", > record.offset(), record.key(), record.value()); > } >
signature.asc
Description: OpenPGP digital signature