Reputation: 574
Suppose there is a producer which is running and I run a consumer a few minutes later. I noticed that the consumer will consume old messages that has been produced by the producer but I don't want that happens. How can I do that? Is there any config parameters in broker to be set and solve this problem?
Upvotes: 0
Views: 1991
Reputation: 1480
It really depends on the use case, you didn't really provide much information about the architecture. For instance - once the consumer is up, is it a long running consumer, or does it just wake up for a short while and consumes new messages arriving?
You can take any of the following approaches:
auto.offset.reset
to latest
consumer.offsetsForTimes
to get the offset of each topic partition for the desired time, and then use consumer.seek
to get to the given offset.auto.offset.reset
policy...Upvotes: 1