码迷,mamicode.com
首页 > 其他好文 > 详细

5 Kafka Streams exactly once semantic

时间:2019-03-08 23:23:24      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:xpl   comm   mic   add   moment   setting   img   kafka   cal   

About Exactly Once Semantic

Since Kafka 0.11 version Kafka support Exactly Once Semantic, which means, that Kafka can give you the grarantee that each messege can be exactly once consumed/produced to/from Kafka.

There are a lot of engineering details, which I wouldn‘t explain here... In this section I want to keep it simple.

Since 0.11 version there is a new implementation for this Exactly Once Semantic, which is idempotent !

It means if a producer send the same messeage twice or retries, Kafka will make sure to only keep one copy of it !

For example in a typically process for Producer:

  • producer send a messeage to Kafka
  • Kafka receive the messege
  • and send back a Acknowledgement to Producer
  • Producer commit Offset (done)

in step two, if Kafka just receive the messege and then lost the network connection, Kafka will not be able to send back the Acknowledgement. In this case Producer will send the messege again by retry. Then will Kafka receive the this messege at this moment twoice. But with Idempotent it will only keep one copy of them.

How to do exactly once in Kafka Streams

Very simple, only add one more line of code in configuration property file:

技术图片

PS: with this feature it could slow down Kafka a little bit.. but it‘s fine :-)

You can also fine tune the setting using commit.interval.ms

 

5 Kafka Streams exactly once semantic

标签:xpl   comm   mic   add   moment   setting   img   kafka   cal   

原文地址:https://www.cnblogs.com/crazy-chinese/p/10498658.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!