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

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

问题描述

我们使用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.

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

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