Kafka - Know if Consumer is up to date

柔情痞子 提交于 2019-12-11 11:58:56

问题


I am using Kafka 0.9.0 with the native Java consumer client. If I have 1 Topic with 1 Partition Can someone tell me if I do: seekToEnd(MyTopic); poll(x);

I will only get the last record, hence I will know that I am in the last position?


回答1:


Yes, you will only get the last (newest) record, because the seekToEnd() method "evaluates lazily" so the end is not calculated until poll() is called. Of course, by the time the poll() method returns, more messages could have been added; so there is no guarantee your offset is "in the last position" except at the instant that the method executes.



来源:https://stackoverflow.com/questions/34905577/kafka-know-if-consumer-is-up-to-date

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!