且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么Kafka Consumer不断收到相同的消息(偏移)

更新时间:2022-11-05 21:46:59

基于所显示的代码.我认为您的问题是新的Consumer是单线程的.如果您轮询一次,然后又不进行其他轮询,则auto.commit.offset将无法正常工作.尝试将代码放入while循环中,看看在再次调用poll时是否提交了偏移量.

Base on the code that you are showing. I think that your problem is that the new Consumer is single threaded. If you poll once and then don't do another poll the auto.commit.offset is not going to work. Try putting your code in a while loop and see if when you call poll again the offset is committed.