The consumer iterator returns MessageAndMetadata which includes the offset. You would need logic in your application to check the offset if it needs to stop processing after a certain offset.
On Wed, Sep 24, 2014 at 12:09:40PM -0600, Kyle Banker wrote: > What are the best ways to replay a portion of a topic in the past? > > I'm using Kafka to process a real-time data stream. Suppose I discover that > all data inside of a six-hour window one day ago was incorrectly processed. > > Since I'm checkpointing offsets in an external database, I can create a new > consumer group and then restore the offsets from the start of the error > window to that group. But how do I get my consumer to stop processing at > the end of the error window? > > More generally, how do I reprocess an arbitrary interval of data within a > topic?