This guide demonstrates a quick setup for working with Kafka and Python using Faust and Docker Compose. You can have Kafka up and running in just a few minutes following these steps.
-
Clone the
kafka-stack-docker-compose
repository:git clone https://github.com/conduktor/kafka-stack-docker-compose
-
Navigate to the repository directory:
cd kafka-stack-docker-compose
-
Start Kafka and ZooKeeper containers:
docker compose -f zk-single-kafka-single.yml up
-
Clone this project:
git clone https://github.com/rawheel/Kafka-Python-Example.git
-
Navigate to the project directory:
cd Kafka-Python-Example
-
Install project dependencies:
pip install -r requirements.txt
-
Start a Faust worker:
faust -A worker worker -l info
-
To produce a Kafka message using the Faust command-line tool, run:
faust -A worker send hello_world 'Hello Folks, Raheel Here!'
-
To produce kafka messages using python code
python producer.py