python连接kafka

Posted by c cm on August 1, 2016

调研了相关client后,选了git上更新频率和关注人数比较占优势的kafka-python

>>> pip install kafka-python

基本语法如下,更多见doc

>>> from kafka import KafkaConsumer
>>> consumer = KafkaConsumer('some_topic', bootstrap_servers=["host:port"])
>>> for msg in consumer:
        print(msg)