说明
下面各值的前提条件相同:当各分区下有已提交的offset时,但之后的行为不同
earliest
当各分区下有已提交的offset时,从提交的offset开始消费;无提交的offset时,从头开始消费
latest(默认取值)
当各分区下有已提交的offset时,从提交的offset开始消费;无提交的offset时,消费新产生的该分区下的数据
演示
- 新建主题
bin/kafka-topics.sh --bootstrap-server hadoop1:9092 --create --topic userlog26 - 启动 sell 生产者,生产消息:
1、2、3、4bin/kafka-console-producer.sh --broker-list hadoop1:9092 --topic userlog26 - 启动服务,获取不到上面的消息
- 查看 消费者组详细信息,发现 offset已经更新到
4bin/kafka-consumer-groups.sh --bootstrap-server hadoop1:9092 --group test-consumer-group4 --describe
none
各分区都存在已提交的offset时,从offset后开始消费;只要有一个分区不存在已提交的offset,则抛出异常