Skip to content
Advertisement

Python-Kafka: Keep polling topic infinitely

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:

JavaScript

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.

Advertisement

Answer

Using confluent_kafka

JavaScript

Using kafka-python

JavaScript
Advertisement