QuinlanGgame
V2EX  ›  Kafka

python 使用 kafka 系列问题 topics 为空

  •  
  •   QuinlanGgame · Dec 7, 2016 · 2879 views
    This topic created in 3456 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
        1
    QuinlanGgame  
    OP
       Dec 7, 2016
    哎呀呀,新手跪求大神帮忙
    phttc
        2
    phttc  
       Dec 8, 2016
    消息订阅啊。。。你客户端得去调用订阅。。。
    QuinlanGgame
        3
    QuinlanGgame  
    OP
       Dec 8, 2016
    @phttc 我代码里面获取到了这个 topics ,这个字典的 value 是个 none ,不应该是 Topic 对象么?是 Topic 对象的话,才可以去 consume 的吧?
    baocaixiong
        4
    baocaixiong  
       Dec 8, 2016
    print client.topics['test'] 有惊喜
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3990 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 47ms · UTC 05:13 · PVG 13:13 · LAX 22:13 · JFK 01:13
    ♥ Do have faith in what you're doing.