簡體   English   中英

卡夫卡消費者不閱讀消息

[英]Kafka Consumer not reading messages

我有在單個節點上運行的Kafka v1.0.1,並且能夠將消息推送到主題,但是以某種方式無法使用下面的python代碼使用來自另一個節點的消息。

from kafka import KafkaConsumer
consumer = KafkaConsumer(
    'kotak-test',
    bootstrap_servers=['kmblhdpedge:9092'],
    auto offset reset='earliest',
    enable auto commit=True,
    group id=' test1',
    value_deserializer-lambda x: loads (x.decode('utf-8')))

for message in consumer:
    message = message.value
    print (message)

我不斷使用以下命令從控制台推送消息:

bin/kafka-console-producer --zookeeper <zookeeper-node>:<port> --topic <topic_name>

而且我可以通過控制台閱讀

您使用的是舊的Zookeeper生產者,但使用的是新的基於Kafka的Consumer。 這些如何工作和存儲偏移量的邏輯並不相同。

您需要在Console Producer上使用--broker-list

與控制台使用者類似,使用--bootstrap-server ,而不是--zookeeper


此外,這些屬性中不應包含空格

auto offset reset='earliest',
enable auto commit=True,
group id=' test1',

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM