0
votes

I want to reset the previous offset corresponding to a given consumer.

Reason: The spring-boot consumer code I wrote my application on was using "earliest" as value for the auto-offset-reset. Since the offset has got stored in __consumer_offsets now, changing the value for auto-offset-reset to latest doesn't work.

Note: I am using kafka version higher than 0.9. Not sure if deleting the consumer will help as I came to know that the offsets are now stored in a topic __consumer_offsets.

1
Could invoke KafkaConsumer.seek to reset the offset for the given partitions. Is that what you want?amethystic

1 Answers

0
votes

You can seek the consumer if your listener implements ConsumerSeekAware. See the documentation.

void registerSeekCallback(ConsumerSeekCallback callback);

void onPartitionsAssigned(Map<TopicPartition, Long> assignments, ConsumerSeekCallback callback);

void onIdleContainer(Map<TopicPartition, Long> assignments, ConsumerSeekCallback callback);

With the callback providing:

void seek(String topic, int partition, long offset);