This is a simple example of using Apache Kafka with Python. Producer produces messages with texts and consumer consumes it.
Follow these steps to get the project up and running on your local machine:
Download the latest Kafka release and extract it to Kafka folder
Start the ZooKeeper service:
cd Kafka
bin/zookeeper-server-start.sh config/zookeeper.properties
Start the Kafka broker service:
bin/kafka-server-start.sh config/server.properties
Once all services have successfully launched, you will have a basic Kafka environment running and ready to use.
Clone the Repository:
git https://github.com/DmitryDubovikov/Kafka-Python.git
cd Kafka-Python
Create a Virtual Environment:
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
Install Dependencies:
pip install -r requirements.txt
Run consumer.py and producer.py in two terminals:
python3 consumer.py
python3 producer.py