Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kafka Consumer seektoBeginning

I did not use a partition to publish to Kafka topic. ProducerRecord(String topic, K key, V value)

In the consumer, I would like to go to the beginning. seekToBeginning(Collection partitions)

Is it possible to seek to beginning without using a partition? Does Kafka assign a default partition?

https://kafka.apache.org/0102/javadoc/org/apache/kafka/clients/producer/ProducerRecord.html https://kafka.apache.org/0102/javadoc/org/apache/kafka/clients/consumer/KafkaConsumer.html

like image 447
Vortex Avatar asked Apr 08 '18 22:04

Vortex


1 Answers

When producing, if you don't explicitely specify a partition, the producer will pick one automatically from your topic.

In your consumer, if your are subscribed to your topic, you can seek to the start of all the partitions your consumer is currently assigned to using:

consumer.seekToBeginning(consumer.assignment())
like image 145
Mickael Maison Avatar answered Sep 28 '22 18:09

Mickael Maison