简体   繁体   English

Kafka Consumer配置——auto.offset.reset如何控制消息消费

[英]Kafka Consumer configuration - How does auto.offset.reset controls the message consumption

I'm trying to understand, how does the ConsumerConfig.auto.offset.reset = latest would affect the message consumption.我试图了解 ConsumerConfig.auto.offset.reset = latest 将如何影响消息消费。

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?例如,我有一个消费者,最初在时间 t1 发送 100 条消息,然后我的消费者在 t1+30 秒启动并运行,然后我的消费者将使用在 t1+30 秒之后发布的消息还是会使用从 t1 开始发布的消息?

It depends.这取决于。

auto.offset.reset only applies when there is no stored offset for the consumer group. auto.offset.reset仅适用于没有为消费者组存储偏移量的情况。

It applies to the following conditions:它适用于以下条件:

  • the first time a consumer group consumes消费者组第一次消费
  • if a consumer doesn't commit any offsets, the next time it is started如果消费者没有提交任何偏移量,则在下次启动时
  • if a consumer group has been expired (7 days by default with modern brokers)如果消费者组已过期(现代经纪人默认为 7 天)
  • if the message the stored offset points to has been removed due to message retention policies (an attempt to read a message that has been purged triggers the application of the rule)如果存储的偏移量指向的消息由于消息保留策略而被删除(尝试读取已被清除的消息会触发规则的应用)

If a consumer commits an offset;如果消费者提交了偏移量; it will start at the last committed offset the next time it is started.它将在下次启动时从最后提交的偏移量开始。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用rest api设置kafka connect auto.offset.reset - how to set kafka connect auto.offset.reset with rest api 为什么 Kafka 消费者会忽略我在 auto.offset.reset 参数中的“最早”指令,从而没有从绝对的第一个事件中读取我的主题? - Why is Kafka consumer ignoring my “earliest” directive in the auto.offset.reset parameter and thus not reading my topic from the absolute first event? spring.kafka.consumer.auto-offset-reset 在 spring-kafka 中如何工作 - How does spring.kafka.consumer.auto-offset-reset works in spring-kafka 如果 auto.offset.reset=earliest 但主题没有消息,将设置什么消费者偏移量 - What consumer offset will be set if auto.offset.reset=earliest but topic has no messages 不清楚Kafka中auto.offset.reset和enable.auto.commit的含义 - Not clear about the meaning of auto.offset.reset and enable.auto.commit in Kafka 卡卡auto.offset.reset查询 - Kaka auto.offset.reset query 即使使用 auto.offset.reset,我的 Java 消费者也无法从 Broker 读取消息 - 最早 - My Java Consumer can't read messages from Broker even with auto.offset.reset - earliest 无论如何对kafka流应用程序中的不同输入主题使用不同的auto.offset.reset策略? - Is there anyway to use different auto.offset.reset strategy for different input topics in kafka streams app? spark-streaming-kafka-0-10 auto.offset.reset 始终设置为 none - spark-streaming-kafka-0-10 auto.offset.reset is always set to none 为什么即使auto.offset.reset = largest,我的消费者为什么每次都读取该主题中的所有消息? - Why is my consumer reading all messages from the topic each time, even when auto.offset.reset=largest?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM