Thought:
Write to the kafka cluster,
read to zk
Be sure to start looking for python to connect to the standard library of kafka. The former kafka-python and pykafka use more mature libraries, and the latter is an upgraded version of Samsa. Go to the article on the Internet to connect in python and use kafka to use samsa to connect to zookeeper and then Using kafka Cluster can meet my needs very well. In the example of pykafka, I also see the support of zk, but kafka-python does not have support for zk, so I chose pykafka as the connection library
conceptual problem
For the cluster of kafaka and zookeeper, when samsa is used, both the producer and the consumer are connected to zookeeper, but I communicate with Fengyun (big data giant, operation and maintenance diaosi reversal), when they use it, the producer directly connects to the kafaka server list , consumers only use zookeeper. This also solves the confusion that I read the pykafka documentation, only consumers can connect to zookeeper, so the problem is solved, just follow the documentation.
producer
1 |
>> > from pykafka import KafkaClient |
consumer
1 |
>> > balanced_consumer = topic.get_balanced_consumer( |