【kafka系列教程19】kafka消息传递保障

本文介绍了Kafka在生产者和消费者间提供的消息传递保障,包括最多一次、至少一次和正好一次的语义。Kafka通过commit消息到日志确保消息的耐久性。0.11.0.0版后,支持幂等性传递以避免重复记录。消费者可以选择读取消息、处理消息并保存位置,实现“至少一次”语义,或先保存位置再处理消息,实现“最多一次”语义。要达到“正好一次”,需结合事务性生产者和目的地存储系统的协调。
摘要由CSDN通过智能技术生成

Now that we understand a little about how producers and consumers work, let's discuss the semantic guarantees Kafka provides between producer and consumer. Clearly there are multiple possible message delivery guarantees that could be provided:
现在我们了解一些关于生产者和消费者是如何工作的,接下来我们来讨论kafka提供了生产者和消费者之间的担保语义。有多种可能的消息传递保证可以提供:

  • At most once—Messages may be lost but are never redelivered.
    最多一次 --- 消息可能丢失,但绝不会重发。
  • At least once—Messages are never lost but may be redelivered.
    至少一次 --- 消息绝不会丢失,但有可能重新发送。
  • Exactly once—this is what people actually want, each message is delivered once and only once.
    正好一次 --- 这是人们真正想要的,每个消息传递一次且仅一次。

 

It's worth noting that this breaks down into two problems: the durability guarantees for publishing a message and the guarantees when consuming a message.

可分解成两个问题:发送消息时的耐久性保障和消费消息的保障。

 

Many systems claim to provide "exactly once" delivery semantics, but it is important to read the fine print, most of these claims are misleading (i.e. they don't translate to the case where consumers or producers can fail, or cases where there are multiple consumer processes, or cases where data written to disk can be lost).

很多消息系统声称提供“正好一次”的传递语义,但是在阅读相关文章时,更多是误导(例如,它们没有解释消费者或生产者可能失败的情况,有多个消费者进程的情况,或写入磁盘的数据可能丢失的情况)

 

Kafka's semantics are straight-forward. When publishing a message we have a notion of the message being "committed" to the log. Once a published message is committed it will not be lost as long as one broker that replicates the partition to which this message was written remains "alive". The definition of alive as well as a description of which types of failures we attempt to handle will be described in more detail in the next section. For now let's assume a perfect, lossless broker and try to understand the guarantees to the

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值