Reputation: 173
I'm trying to consume data from kafka server, I'm using @Kafkalistener
annotation.
The problem is that I'm getting all the messages every time I restart my application. How do I save the last consumed offset in my application and use it to consume next messages?
Upvotes: 6
Views: 5265
Reputation: 1359
This tutorial has the answer: https://www.codenotfound.com/spring-kafka-boot-example.html
The kafka.consumer.auto-offset-reset property needs to be set to 'earliest' which ensures the new consumer group will get the message sent in case the container started after the send was completed.
So you should set it to latest as per your requirement
Upvotes: 3