问题
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