Kafka偏移量管理

Kafka offset management

我们正在使用 Kafka 0.10...我在网上(和文档中)看到了一些关于当 enable.auto.commit 为 TRUE 时如何在 kafka 中管理偏移量的相互矛盾的信息。检索消息的相同 poll() 方法是否也按配置的时间间隔处理提交?

如果我在单线程应用程序中从轮询中检索消息,在同一线程中处理消息直至完成(包括处理错误),这意味着在我的处理完成之前不会再次调用 poll(),然后我假设没有丢失消息的恐惧,对吗?这仅在 poll() 尝试在后续调用时提交(当然,如果 auto.commit.interval.ms 已通过)才有效。如果在收到消息后立即完成提交(在我的应用程序处理消息之前),这对我们不起作用....

这很重要,因为我想确定如果我们使用自动提交策略我们不会丢失消息。重复的消息对我们来说是可以容忍的,我们只是不能容忍丢失的数据。

感谢您的澄清!

Does the same poll() method that retrieves messages also handle the commits at the configured intervals?

是的。 (如果enable.auto.commit=true.)

If i retrieve messages from poll in a single threaded application, process the messages to completion (including handling errors) in the SAME thread, meaning poll() will not be invoked again until after my processing is complete, then I presume there is no fear in losing messages, correct?

是的。

This only works if poll() attempts the commit at the subsequent invocation (if the auto.commit.interval.ms has passed, of course)

这正是它的做法。

有关详细信息,请参阅此处:http://docs.confluent.io/current/clients/consumer.html