Kafka Consumer自动提交如何工作? [英] How does kafka consumer auto commit work?

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

问题描述

我正在阅读:

自动提交提交偏移量的最简单方法是允许 消费者为您做.如果您配置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()调用 在后台以设置的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 Consumer自动提交如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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