This repository provides code for this simple Kafka tutorial.
To execute the code, you will need:
Clone this repository
git clone [email protected]:Boyu1997/kafka-light-bulb.git
cd kafka-light-bulb
Start the Kafka cluster
docker-compose up
Note: if you encountered issue and need to restart the Kafka cluster, make sure to delete the data folder by running rm -rf data before restarting using docker-compose up.
Setup virtual environment for running Python code
python3 -m venv venv
source venv/bin/activate
pip3 install -r requirements.txt
Run the producer script, the producer takes three optional inputs
--key="KEY_STRING", Kafka log key name, default to1--topic="TOPIC_STRING", Kafka topic to publish to, default tolight_bulb--string="DATA_STRING", string data to be sended as Morse code, the string data must contain only character A-Z, default toABC
python3 producer.py
python3 producer.py --key="123" `--STRING="XYZ"`
Run the consumer script
python3 consumer.py