Search code examples
javastreamapache-kafkaoffsetconsumer

Reset consumer offset to the beginning from Kafka Streams


I am using Kafka streams and want to reset some consumer offset from Java to the beginning. KafkaConsumer.seekToBeginning(...) sounds like the right thing to do, but I work with Kafka Streams:

KafkaStreams streams = new KafkaStreams(builder, props);
...
streams.start();

I guess that depending on the concrete streams pipeline I define this would create several consumers under the hood. Can I get access to those? Or is there some other way to reset offsets programmatically?


Solution

  • Since you are using Kafka Streams you will want to reset not only the consumer offsets but also the Streams internal state store.

    Fortunately there is a Streams Application Reset Tool provided with Kafka.

    See https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Streams+Application+Reset+Tool