我正在使用 C 库 ( librdkafka
) 来编写 Kafka 消费者。我需要知道给定主题的分区的最后偏移量(以及滞后)。我知道使用 Python 是可能的(来自 Stackoverflow 上的类似帖子),但我没有找到在 C 中实现它的方法......谢谢。
1 回答
1
您可以使用query_watermark_offsets
它来获取分区的高偏移量和低偏移量。
query_watermark_offsets (const std::string &topic, int32_t partition, int64_t *low, int64_t *high, int timeout_ms)=0
查询代理以获取分区的低(最旧/开始)和高(最新/结束)偏移量。
偏移量分别在 *low 和 *high 中返回。
成功返回
RdKafka::ERR_NO_ERROR
或失败返回错误代码。
于 2019-07-04T08:55:34.567 回答