Kafka Consumer配置-auto.offset.reset如何控制消息使用 [英] Kafka Consumer configuration - How does auto.offset.reset controls the message consumption

查看:297
本文介绍了Kafka Consumer配置-auto.offset.reset如何控制消息使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图了解,ConsumerConfig.auto.offset.reset = Latest将如何影响消息使用.

I'm trying to understand, how does the ConsumerConfig.auto.offset.reset = latest would affect the message consumption.

例如,我有一个使用者,最初在时间t1发送100条消息,然后我的使用者在t1 + 30秒启动并运行,然后我的使用者会消耗t1 + 30秒之后发布的消息,还是会消耗消息从t1开始发布?

For example I've a consumer, sending 100 messages initially at time t1 and then my consumer is up and running at t1+30 sec, then would my consumer consume the messages published after t1+30 sec or will it consume messages published t1 onwards?

推荐答案

这要视情况而定.

auto.offset.reset 仅在没有为使用者组存储偏移量的情况下适用.

auto.offset.reset only applies when there is no stored offset for the consumer group.

它适用于以下条件:

  • 消费群体第一次消费
  • 如果使用者未提交任何补偿,则在下次启动时
  • 如果某个消费群体已过期(现代经纪人默认为7天)
  • 如果由于消息保留策略已删除了存储的偏移量指向的消息(尝试读取已清除的消息会触发规则的应用)

如果消费者承诺补偿;它将在下一次启动时从最后提交的偏移量开始.

If a consumer commits an offset; it will start at the last committed offset the next time it is started.

这篇关于Kafka Consumer配置-auto.offset.reset如何控制消息使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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