Suppose that you have a Kafka Topic with some data, and you connect to it with Kafka Consumer with a new group.id. But this consumer does not read messages from the beginning of the topic.
Consumer Config has a specific property auto.offset.reset
, which indicates which offset will be assigned to the consumer with the new group.id.
The property takes two values:
- earliest. Then, when connecting to the Consumer topic with a new group.id, it will read the topic from the beginning
- latest. Then, when connecting to the Consumer topic with a new group.id, it will read the topic from the last fixed Kafka offset.
An example of how to set up a property for a Kafka Consumer:
Properties properties = new Properties();
...
properties.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
...
Telegram channel
If you still have any questions, feel free to ask me in the comments under this article or write me at promark33@gmail.com.
If I saved your day, you can support me 🤝