user2407164
user2407164

Reputation: 71

how to stop kafka python consumer after getting a record I want to , and do my rest of the processes

I would like to consume all the messages from beginning each time I run the consumer in python and stop if I get a desired record and end the consumer then continue with rest of my processes.

Upvotes: 0

Views: 1058

Answers (1)

mukesh210
mukesh210

Reputation: 2892

You can use seek each time you start your consumer(use OFFSET_BEGINNING). This will set consume position for partition to offset. After this, keep processing messages as usual.

When you encounter the record after which you need to stop Consumer, use close

Upvotes: 1

Related Questions