0

我需要每 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()
4

1 回答 1

1

调用consumer.endOffsets()是更好的方法。

第一种方法需要实际分配主题,这听起来像您不需要。

于 2019-03-17T10:32:26.793 回答