卡夫卡消费者寻求开始 [英] Kafka Consumer seektoBeginning
问题描述
我没有使用分区发布到 Kafka 主题.ProducerRecord(String topic, K key, V value)
I did not use a partition to publish to Kafka topic. ProducerRecord(String topic, K key, V value)
在消费者方面,我想从头说起.seekToBeginning(集合分区)
In the consumer, I would like to go to the beginning. seekToBeginning(Collection partitions)
是否可以在不使用分区的情况下寻求开始?Kafka 是否分配了默认分区?
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.htmlhttps://kafka.apache.org/0102/javadoc/org/apache/kafka/clients/consumer/KafkaConsumer.html
推荐答案
制作时,如果您没有明确指定分区,制作者会自动从您的主题中选择一个.
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())
这篇关于卡夫卡消费者寻求开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!