public static void main(String[] args) {
Properties props = new Properties();
props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "");
props.put(ConsumerConfig.GROUP_ID_CONFIG, "");
props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
props.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, "false");
props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, JsonDeserializer.class);
props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, JsonDeserializer.class);
KafkaConsumer consumer = new KafkaConsumer<>(props);
TopicPartition topicPartition = new TopicPartition("topic", 9);
consumer.assign(Collections.singletonList(topicPartition));
consumer.seek(topicPartition, 675);
while (true) {
ConsumerRecords records = consumer.poll(Duration.ofMillis(10000));
for (ConsumerRecord record : records) {
}
consumer.commitSync();
}
}