How to fix not receiving kafka messages in python but receiving the same messages in shell?

Deadly 提交于 2019-12-20 05:50:52

问题


I want to consume messages coming in a kafka topic. I am using debezium which oplogs the mongodb changes and puts them in the kafka queue. I am able to connect to kafka using my python code, list the kafka topics. Although, when I want to consume the messages, its all blank whereas the same topic when consumed from the shell gives messages, performs perfectly.

from kafka import KafkaConsumer

topic = "dbserver1.inventory.customers"
# consumer = KafkaConsumer(topic, bootstrap_servers='localhost:9092', auto_offset_reset='earliest', auto_commit_enable=True)
consumer = KafkaConsumer(topic)
print("Consumer connected!")
# print("Topics are {}".format(consumer.topics()))
for message in consumer:
    print(message)

来源:https://stackoverflow.com/questions/55696197/how-to-fix-not-receiving-kafka-messages-in-python-but-receiving-the-same-message

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!