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.
Asked
Active
Viewed 1,013 times
1

Giorgos Myrianthous
- 36,235
- 20
- 134
- 156

Stéphane Michaut
- 21
- 1
- 3
1 Answers
2
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.

Giorgos Myrianthous
- 36,235
- 20
- 134
- 156
-
Thanks you very much: rd_kafka_query_watermark_offsets does the trick and high offset is exactly what I need ! – Stéphane Michaut Jul 04 '19 at 12:38