简体   繁体   English

如果我在kafka流中设置commit.interval.ms =的值,是否可以提交偏移量?

[英]if i set value of commit.interval.ms = in kafka stream, Whether it will be able to commit offset?

I am trying to understand behavior of kafka streams related to offset commit. 我试图了解与偏移提交相关的kafka流的行为。 Streams commit offset manually as auto commit is set to " false " in Streams. 由于在Streams中自动提交设置为“ false ”,因此Streams手动提交偏移。 What if I keep commit.interval.ms = 0 , whether streams will work correctly? 如果我保持commit.interval.ms = 0怎么commit.interval.ms = 0 ,流是否可以正常工作?

What are you trying to accomplish by setting that config parameter to zero milliseconds? 通过将该config参数设置为零毫秒,您试图实现什么? The default is 100 milliseconds for Streams, per the official docs: 根据官方文档,流的默认值为100毫秒:

Note, if 'processing.guarantee' is set to 'exactly_once', the default value is 100, otherwise the default value is 30000. 注意,如果“ processing.guarantee”设置为“ exactly_once”,则默认值为100,否则默认值为30000。

From the official Kafka Streams docs - https://kafka.apache.org/documentation/#streamsconfigs 来自Kafka Streams官方文档-https: //kafka.apache.org/documentation/#streamsconfigs

Updated: 更新:

Based on your comment, I believe that yes, you should be able to store commits in an external database, and that commit interval configuration would still apply. 根据您的评论,我相信是的,您应该能够将提交存储在外部数据库中,并且提交间隔配置仍然适用。

Also, make sure to go over the docs on the implications of storing offsets outside of Kafka - https://kafka.apache.org/20/javadoc/org/apache/kafka/clients/consumer/KafkaConsumer.html#rebalancecallback 另外,请务必仔细阅读有关在Kafka外部存储偏移量的含义的文档-https: //kafka.apache.org/20/javadoc/org/apache/kafka/clients/consumer/KafkaConsumer.html#rebalancecallback

If you set commit.interval.ms = 0 Kafka Streams will commit "as soon as possible". 如果设置commit.interval.ms = 0 Kafka Streams将“尽快”提交。 In the implementation, there is a poll-process-loop that checks if a commit is required. 在实现中,有一个poll-process-loop检查是否需要提交。 If you set commit.interval.ms = 0 this check will evaluate to true every time and thus commit will happen each time. 如果将commit.interval.ms = 0设置commit.interval.ms = 0此检查每次都会评估为true ,因此每次都会进行提交。

When the commit condition is checked is an internal implementation detail and there is no public contract how ofter the condition is checked. 当检查提交条件时,这是内部实现细节,并且没有公共合同对条件进行检查。 Note, it's not recommended to commit too frequently because it put additional load on Kafka Streams client and the brokers because committing is a sync operation and not for free. 请注意,不建议频繁提交,因为这样会给Kafka Streams客户端和代理增加额外的负担,因为提交是同步操作,而不是免费的。

From the comment: 从评论:

We want to check whether we can store commits in external db..so we want to know can we achieve offset commit management solely on db side 我们想检查是否可以将提交存储在外部db ..中,所以我们想知道是否可以仅在db端实现偏移提交管理

Using Streams API, you cannot store offsets in an external DB. 使用Streams API,您不能将偏移量存储在外部数据库中。 Kafka Streams uses Kafka's group management and commit API and you cannot change this. Kafka Streams使用Kafka的群组管理和提交API,您无法更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM