Three files are involved to run the ping pong test.
- docker-compose.yaml - is used to download the images and run the kafaka and zookeeper as services locally.
- produce.py - is used to simulate messages to kafka
- consumer.py - is used to read the messages and act on the give values.
- requirements.txt - is used to install libraries for the code to run - libraries for kafka and other stuf.
In order to run this scenario you need to follow the procedure:
- Create an virtual envirnment -
pipenv install --three
- Activate the virtual env. -
pipenv shell
- Install the libraries -
pip install -r requirements.txt
- Install docker if its not present
- Run the docker compose - this will download the kafka and zookeeper images and run them with the default ports and settings. -
docker-compose -f docker-compose.yml up -d
- Once the images are up and ready you can start the produce.py script with the proper message -
python produce.py
- Open a new terminal and start the consumer -
python consume.py
You should see the result in real time if both terminals are open and run properlly.