- Follow steps 1 through 4 of Java Client for publishing and consuming messages from Apache Kafka entry to start Zookeeper and Kafka server
- Follow these steps to install Kafka python client
git clone https://github.com/mumrah/kafka-python pip install ./kafka-python
-
Next create a Producer.py python script to publish message to
pythontest
topic, the basic concept here is you connect to Kafka server onlocalhost:9092
port and then publish a message to a particular topic -
Now create Consumer.py script that consumes messages from
pythontest
topic and writes them to console.
Python client for publishing and consuming message from Apache Kafka
In the Java Client for publishing and consuming messages from Apache Kafka i talked about how to create a Java Client for publishing and consuming messages from Kafka. I wanted to try same thing using Python so i followed these steps
the consumer and producer aren't using the same topic
ReplyDeleteChange "pythontest" to "test" in producer. :)
ReplyDeletewhat is KafkaClient port should be
ReplyDeleteIam getting this error while running producer.py code
ReplyDeletekafka = KafkaClient("localhost:9092")
TypeError: __init__() takes exactly 1 argument (2 given)
SimpleConsumer and SimpleProducer is deprecated, you should update to KafkaProducer and KafkaConsumer.
ReplyDelete