kafka 消费者自动提交如何工作? [英] How does kafka consumer auto commit work?

查看:44
本文介绍了kafka 消费者自动提交如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读这个:

自动提交提交偏移量的最简单方法是允许消费者为你做.如果配置 enable.auto.commit=true,然后每五秒消费者将提交最大的偏移量您的客户从 poll() 收到.五秒间隔是默认并通过设置 auto.commit.interval.ms 来控制.只是像消费者中的其他一切一样,自动提交是由驱动的通过轮询循环.每当您进行轮询时,消费者都会检查是否到了时间提交,如果是,它将提交它在上次投票.

Automatic Commit The easiest way to commit offsets is to allow the consumer to do it for you. If you configure enable.auto.commit=true, then every five seconds the consumer will commit the largest offset your client received from poll(). The five-second interval is the default and is controlled by setting auto.commit.interval.ms. Just like everything else in the consumer, the automatic commits are driven by the poll loop. Whenever you poll, the consumer checks if it is time to commit, and if it is, it will commit the offsets it returned in the last poll.

可能是因为我的英语不好,但我不完全理解这个描述.

Maybe issue that my English is not good but I do not fully understood this description.

假设我使用默认间隔的自动提交 - 5 秒,轮询每 7 秒进行一次.在这种情况下,提交将每 5 秒或每 7 秒发生一次?

Let's say I use auto-commit with default interval - 5 sec and poll happens every 7 sec. At this case, a commit will happen every 5 sec or every 7 sec?

如果民意调查每 3 秒进行一次,您能否澄清行为?提交是每 5 秒还是每 6 秒发生一次?
我已阅读 这个:

Can you clarify behaviour if poll will happen every 3 sec? Will commit happen every 5 sec or every 6 sec?
I have read this one:

自动提交:您可以将 auto.commit 设置为 true 并设置auto.commit.interval.ms 属性,以毫秒为单位.一次您已启用此功能,Kafka 消费者将提交偏移量响应其 poll() 调用收到的最后一条消息.poll() 调用在后台以 set auto.commit.interval.ms 发出.

Auto commits: You can set auto.commit to true and set the auto.commit.interval.ms property with a value in milliseconds. Once you've enabled this, the Kafka consumer will commit the offset of the last message received in response to its poll() call. The poll() call is issued in the background at the set auto.commit.interval.ms.

它与答案相矛盾.

你能详细解释一下这个东西吗.

Can you explain this stuff in details.

假设我有这样的图表:

0 秒 - 投票
4 秒 - 投票
8 秒 - 投票

0 sec - poll
4 sec - poll
8 sec - poll

什么时候提交偏移量,什么时候提交?

When does offset will be committed and when which one?

推荐答案

自动提交检查在每次轮询中调用,它检查经过的时间是否大于配置的时间.如果是,则提交偏移量.

The auto-commit check is called in every poll and it checks that the time elapsed is greater than the configured time. If so, the offset is committed.

如果提交间隔为 5 秒并且轮询在 7 秒内发生,则提交只会在 7 秒后发生.

In case the commit interval is 5 seconds and poll is happening in 7 seconds, the commit will happen after 7 seconds only.

这篇关于kafka 消费者自动提交如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆