Search code examples
apache-kafkaconsumer

Where can I get all the message from one topic using kafka java api


In the command line, I can use "--from-beginning" to get all the messages in one topic, but how can I get the same effort when I code a java program ,and I'm using High Level Consumer api.


Solution

  • while creating the consumer properties you can add

    props.put("auto.offset.reset", "smallest"); to start reading from the beginning