我需要每 N 秒获取所有主题分区的最后偏移量(出于缓存目的)。我API应该为此使用什么?我想,我需要最可靠、最快捷的方式。
我知道两种方法:
1)第一个:
//assign the topic
consumer.assign();
//seek to end of the topic
consumer.seekToEnd();
//the position is the latest offset
consumer.position();
2)第二个:
consumer.endOffsets()