卡夫卡消费者寻求开始 [英] Kafka Consumer seektoBeginning

查看:126
本文介绍了卡夫卡消费者寻求开始的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有使用分区发布到Kafka主题. ProducerRecord(字符串主题,K键,V值)

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.html https://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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆