Reputation: 162
I am looking for some guidance around replay message strategy from a Kafka topic utilizing Spring Cloud Stream 3.x / Kafka binder implementations -
Replay specific messages [ for ex. by timestamp window ] from a topic. How to reset offsets for all or some consumers within a consumer group?
Is it possible to replay from a specific partition of the topic [ if we know partitions for messages we are interested in replaying ]?
In general, what are the best practices around message replay. Thank you for your time.
Upvotes: 1
Views: 568
Reputation: 174759
Add a rebalance listener bean and it will be wired into the binder...
@Bean
KafkaBindingRebalanceListener rebal() {
return new KafkaBindingRebalanceListener() {
@Override
public void onPartitionsAssigned(String bindingName, Consumer<?, ?> consumer,
Collection<TopicPartition> partitions, boolean initial) {
consumer.seekToBeginning(partitions);
}
};
}
You can use any consumer seek operation; you can also call consumer.offsetsForTimes(...)
etc.
The initial
flag is true for the first rebalance, false, for others.
Upvotes: 2