Reputation: 21
I am using C library (librdkafka
) to write a Kafka consumer. I need to know the last offset of a partition of a given topic (and the lag too). I know it is possible with Python (from a similar post on Stackoverflow) but I didn't find a way to do it in C... Thanks.
Upvotes: 1
Views: 1495
Reputation: 39800
You can use query_watermark_offsets
in order to get both high and low offsets of a partition.
query_watermark_offsets (const std::string &topic, int32_t partition, int64_t *low, int64_t *high, int timeout_ms)=0
Query broker for low (oldest/beginning) and high (newest/end) offsets for partition.
Offsets are returned in *low and *high respectively.
Returns
RdKafka::ERR_NO_ERROR
on success or an error code on failure.
Upvotes: 2