QuinlanGgame
V2EX  ›  Kafka

python 使用 kafka 系列问题 topics 为空

  •  
  •   QuinlanGgame · Dec 7, 2016 · 3237 views
    This topic created in 3620 days ago, the information mentioned may be changed or developed.

    代码

    from pykafka import KakaClient
    client = KafkaClient(
    zookeeper_hosts='127.0.0.1:2181')
    print client, dir(client), client.brokers, client.cluster
    print client.topics
    

    输出

    {'test': None, 'syslog-topic': None}
    

    我在 shell 里面通过

    >>bin/kafka-console-producer.sh --broker-list localhost:9092 --topic syslog-topic
    >>asdkasdjkasjd
    

    输入了一些字符串 为什么 topics 字典里面还是 None

    4 replies  •  2016-12-08 16:46:21 +08:00
    QuinlanGgame
    QuinlanGgame
    OP
    Dec 7, 2016
    1
    哎呀呀,新手跪求大神帮忙
    phttc
    phttc
    Dec 8, 2016
    2
    消息订阅啊。。。你客户端得去调用订阅。。。
    QuinlanGgame
    QuinlanGgame
    OP
    Dec 8, 2016
    3
    @phttc 我代码里面获取到了这个 topics ,这个字典的 value 是个 none ,不应该是 Topic 对象么?是 Topic 对象的话,才可以去 consume 的吧?
    baocaixiong
    baocaixiong
    Dec 8, 2016
    4
    print client.topics['test'] 有惊喜
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4599 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 09:07 · PVG 17:07 · LAX 01:07 · JFK 04:07
    ♥ Do have faith in what you're doing.