I am using python-kafka to listen to a kafka topic and use that the records. I want to keep it polling infinitely without any exit. This is my code below:
def test():
consumer = KafkaConsumer('abc', 'localhost:9092', auto_offset_reset='earliest')
for msg in consumer:
print(msg.value)
This code just reads the data and exits directly. Is there a way to keep listening to topics even if message is not pushed to it?
Any relevant example where the topic is continuously monitored is also great for me.