Can receive messages using cli, but not getting messages from kafka python

276 Views Asked by At

I am using AWS MSK Kafka managed streaming service and all of a sudden I am not receiving any messages through my consumer. I am using kafka-python and the weird thing is that when I open up my cli and create a new consumer with the exact same code, I receive the messages just fine. If I restart the kafka broker, only then will I get messages. Any idea what the issue could be?

>>> consumer = KafkaConsumer(
...                 bootstrap_servers=[...],
...                 auto_offset_reset='earliest',
...                 enable_auto_commit=True,
...                 group_id='my-client-id',
...                 api_version=(2, 2, 1))
>>> consumer.subscribe(['hello_world', 'foo_bar'])
>>> for message in consumer:
...     print(message)
0

There are 0 best solutions below