Description
Bug description
While using KafkaItemReader to read the data from Kafka it always starts from 0th offset,if the previously commited offset is 1000 but it is starting from 0 always
Environment
Springboot-2.3.4.RELEASE
SpringBatch-2.3.4.RELEASE
java -Amazon coretto 11
Steps to reproduce
keep this property in kafka itemreader and try to consume two times
KafkaItemReader<String, Member> memberKafkaItemReader() {
Properties props = new Properties();
props.put(JsonSerializer.ADD_TYPE_INFO_HEADERS, false);
props.putAll(this.memberProperties.buildConsumerProperties());
props.put(ConsumerConfig.GROUP_ID_CONFIG, appProperties.MEMBER_GROUP_ID);
props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, appProperties.BOOTSTRAP_SERVERS_CONFIG);
props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, JsonDeserializer.class);
props.put(JsonDeserializer.VALUE_DEFAULT_TYPE, "com.sample.consumer.test");
props.put(ConsumerConfig.MAX_POLL_RECORDS_CONFIG, "100");
props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
props.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, "true");
props.put("auto.commit.interval.ms","500");
return new KafkaItemReaderBuilder<String, Member>()
.partitions(0)
.consumerProperties(props)
.name("test-reader")
.saveState(true)
.topic(appProperties.MEMBER_CONSUME_TOPIC)
.build();
Expected behavior
In first Run it has to consume from offset 0
in second run it has to continue from the last run offset.
problem
But every time it is starting from the 0th offset