How to commit manually with Kafka Stream?

后端 未结 1 489
隐瞒了意图╮
隐瞒了意图╮ 2020-11-29 10:15

Is there a way to commit manually with Kafka Stream?

Usually with using the KafkaConsumer, I do something like below:

while (true) {
            


        
相关标签:
1条回答
  • 2020-11-29 10:45

    Commits are handled by Streams internally and fully automatic, and thus there is usually no reason to commit manually. Note, that Streams handles this differently than consumer auto-commit -- in fact, auto-commit is disabled for the internally used consumer and Streams manages commits "manually". The reason is, that commits can only happen at certain points during processing to ensure no data can get lost (there a many internal dependencies with regard to updating state and flushing results).

    For more frequent commits, you can reduce commit interval via StreamsConfig parameter commit.interval.ms.

    Nevertheless, manual commits are possible indirectly, via low-level Processor API. You can use the context object that is provided via init() method to call context#commit(). Note, that this is only a "request to Streams" to commit as soon as possible -- it's not issuing a commit directly.

    0 讨论(0)
提交回复
热议问题