卡夫卡时间戳顺序是否对应​​于偏移量? [英] Is Kafka timestamp order corresponding to the offset?

查看:87
本文介绍了卡夫卡时间戳顺序是否对应​​于偏移量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们将kafka用于消息队列,我们​​的业务要求消息时间戳必须与偏移量具有相同的顺序,这意味着:如果存在消息m1和消息m2,并且(m1.timestamp

We use kafka for our message queue,Our business required that message timestamp must with the same order with the offset, that means: if there are message m1 and message m2, and (m1.timestamp

推荐答案

这取决于所使用的时间戳类型,有两种类型:

It depends on the timestamp type used, there are two types:

  • CreateTime -创建生产者记录时即分配时间戳,因此在发送之前.可以重试,因此不能保证保留顺序.
  • LogAppendTime -在将记录附加到代理上的日志时分配时间戳.在这种情况下,将保留每个分区的排序.多个消息可能会分配相同的时间戳.
  • CreateTime - timestamp is assigned when producer record is created, so before sending. There can be retries, so there is no guarantee that ordering is preserved.
  • LogAppendTime - timestamp is assigned when record is appended to the log on the broker. In that case ordering per partition is preserved. Multiple messages might get the same timestamp assigned.

默认情况下,使用 CreateTime .要更改此设置,请为代理设置 log.message.timestamp.type 或为特定主题设置 message.timestamp.type .

By default, CreateTime is used. To change this, set log.message.timestamp.type for broker or message.timestamp.type for particular topic.

这篇关于卡夫卡时间戳顺序是否对应​​于偏移量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆