我希望我没有犯错,但我记得在 Kafka 文档中它提到使用高级 API 不能从特定偏移量开始读取消息,但有人提到它会改变。
现在是否可以使用高级 API 从特定分区和特定偏移量读取消息?你能给我一个例子吗?
我正在使用 kafka 0.8.1.1。
提前致谢。
最佳答案
你可以用 kafka 0.9 做到这一点:
http://kafka.apache.org/090/javadoc/org/apache/kafka/clients/consumer/KafkaConsumer.html
public void seek(TopicPartition partition, long offset)
Overrides the fetch offsets that the consumer will use on the next poll(timeout). If this API is invoked for the same partition more than once, the latest offset will be used on the next poll(). Note that you may lose data if this API is arbitrarily used in the middle of consumption, to reset the fetch offsets
关于apache-kafka - 使用高级 API 从特定偏移量开始读取 kafka 消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34310257/