.seek() and .assign() API may help you. These APIs are also helpful to replay data from a specific offset.
To use these API, make the following changes:
- Remove the
group.idfrom the consumer properties (we don’t use consumer groups anymore). - Remove the subscription to the topic.
- Use consumer
assign()andseek()APIs.
7 of partition 0 of the topic demo_java.
Partition Offset
Make sure the partition offset of partition0 of the topic demo_java is at least 7. Produce a number of messages to the topic to achieve that.
Run the application. The console of the application will display the selected messages.
Next: Java Consumer in Threads