kafka使用high api怎样确保不丢失消息,不重复发送,消息只读取一次( 二 )
■网友
最近正好在看kafka权威指南(Kafka: The De?nitive Guide) 介绍了利用数据库事务的方式保证commit offset提交正确性的方式。当然这样的话offset就不会保存在kafka中。可能对你有所启发
:在Consuming Records withSpeci?cOffsets这一章
But what if we wrote both the record and the offset to the database, in one transac‐
tion? Then we’ll know that either we are done with the record and the offset is com‐
mitted or we are not and the record will be reprocessed...........................................
我刚看完了这一章最后一段话
There are many different ways to implement exactly-once semantics by storing offsets
and data in an external store, but all of them will need to use the ConsumerRebalance
Listener and seek() to make sure offsets are stored in time and that the consumer
starts reading messages from the correct location.
如果想实现仅仅一次的语义的话方法还是有的,但是明显如果使用kafka内部的offset提交机制的话并不能实现。书里面也说过类似的话:
As long as the records are written to a database and the offsets
to Kafka, this is impossible.
kafka最初是领英公司为解决需求的产品
权威指南的作者也是kafka的设计者之一我觉得权威性还是可信的
■网友
【kafka使用high api怎样确保不丢失消息,不重复发送,消息只读取一次】 具体的可以看看为这篇文章:Kafka消息投递语义-消息不丢失,不重复,不丢不重
■网友
针对消息丢失,撇开api及业务的保证,kafka其本身也不是确保消息完全的不丢,如,副本未同步完全,leader节点出现故障;kafka消息刷磁盘机制。
■网友
高级api本身就能满足不丢消息不重复读消息,找个样例跑一下就行了。只不过实现的机制非常傻,可靠性极差。说一下,kafka本身就是一个非常傻的日志收集系统。注意,是日志收集系统不是消息系统!负载均衡以及消息可靠性顺序性保证都极差,基本都要靠使用者自己操心。在我看来,kafka只是分布式的把发送端提交的信息记录在服务端的文件里,仅此而已。
推荐阅读
- 『先进』长江流域最先进洗舱站在宁投运 油可分离回收,水能循环使用
- 汽车|冬天怎样让车内温度快速升高?座椅加热的最佳使用方式二,外循环的作用总结
- 汽车|迈凯伦Artura不再使用迈凯伦祖传V8引擎了?
- python的html5lib这个库咋使用啊我在网上也没有找到相关文档
- win7中本地连接跟无线网卡同时使用时是怎么样的模式
- 可不可能利用网盘的秒传功能使用伪造的MD5(或其他信息)值进行文件分享
- 为啥很多企业给用户发邮件会使用noreply/no-reply@xx.xx的邮箱
- win10激活的问题
- 全网通的mate8能不能插美国手机卡,在美国使用
- 汽车|首批200辆吉利新能源出租车在长交付使用,充电半小时电量可达80%
