【发布时间】:2019-08-07 21:53:09
【问题描述】:
我需要每 N 秒获取所有主题分区的最后偏移量(用于缓存目的)。我应该使用什么API?我想,我需要最可靠、最快捷的方式。
我知道两种方法:
1)First one:
//assign the topic
consumer.assign();
//seek to end of the topic
consumer.seekToEnd();
//the position is the latest offset
consumer.position();
2) 第二个:
consumer.endOffsets()
【问题讨论】:
标签: java apache-kafka kafka-consumer-api