我想重置对应于给定消费者的先前偏移量 .
原因:我编写应用程序的spring-boot使用者代码使用“最早”作为自动偏移重置的值 . 由于偏移现在已存储在__consumer_offsets中,因此将auto-offset-reset的值更改为latest不起作用 .
注意:我使用的kafka版本高于0.9 . 不知道删除消费者是否有帮助,因为我知道偏移现在存储在主题__consumer_offsets中 .
如果您的监听器实现 ConsumerSeekAware ,您可以寻求消费者 . 见the documentation .
ConsumerSeekAware
void registerSeekCallback(ConsumerSeekCallback callback); void onPartitionsAssigned(Map<TopicPartition, Long> assignments, ConsumerSeekCallback callback); void onIdleContainer(Map<TopicPartition, Long> assignments, ConsumerSeekCallback callback);
随回调提供:
void seek(String topic, int partition, long offset);
1 回答
如果您的监听器实现
ConsumerSeekAware
,您可以寻求消费者 . 见the documentation .随回调提供: