Part 1 of the lab is used to learn about Kafka. It simulates part of an order system for a restaurant. There is a producer service that sends orders to Kafka, and two consumers that consume the orders. One consumer is responsible for sending notifications to the customers, while the other consumer is responsible for updating the inventory.
Navigate into the Part 1 directory (1_kafka_fundamentals) first. All the
commands below assume that you are inside the 1_kafka_fundamentals directory.
cd 1_kafka_fundamentals/Then install the dependencies.
pip install -r requirements.txt# This is executed to create the required volume directories
chmod u+x project_setup.sh
sed -i 's/\r$//' project_setup.sh
./project_setup.shUse the confluentinc/cp-kafka image to create a Kafka container.
The Kafka container uses KRaft as the consensus mechanism instead of using Zookeeper.
docker compose -f docker-compose.yaml up --buildpython consumer_order_notification.py
python consumer_order_inventory.pypython producer_order.py# Stop all services AND delete all stored data
docker-compose down -vchmod u+x project_cleanup.sh
sed -i 's/\r$//' project_cleanup.sh
./project_cleanup.sh