Skip to content

Latest commit

 

History

History
65 lines (48 loc) · 1.5 KB

File metadata and controls

65 lines (48 loc) · 1.5 KB

Part 1: Kafka Fundamentals

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/

Step 1: Install the Dependencies

Then install the dependencies.

pip install -r requirements.txt

Step 2: Execute the Project Setup Script

# This is executed to create the required volume directories
chmod u+x project_setup.sh
sed -i 's/\r$//' project_setup.sh
./project_setup.sh

Step 3: Start the Kafka Service

Use 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 --build

Step 4: Start the Consumers

python consumer_order_notification.py
python consumer_order_inventory.py

Step 5: Start the Producer

python producer_order.py

Step 6: Project Cleanup

# Stop all services AND delete all stored data
docker-compose down -v
chmod u+x project_cleanup.sh
sed -i 's/\r$//' project_cleanup.sh
./project_cleanup.sh