Streaming data does not have to be simple text. Many of us are familiar with streaming video content and audio (e.g. music) files.
Streaming data can be structured (e.g. csv files) or semi-structured (e.g. json data).
We'll work with two different types of data, and so we'll use two different Kafka topic names. See .env.
Before starting, ensure you have completed the setup tasks in https://github.com/denisecase/buzzline-01-case and https://github.com/denisecase/buzzline-02-case first. Python 3.11 is required.
Once the tools are installed, copy/fork this project into your GitHub account
and create your own version of this project to run and experiment with.
Name it buzzline-03-yourname
where yourname is something unique to you.
Follow the instructions in FORK-THIS-REPO.md.
Follow the instructions in MANAGE-VENV.md to:
- Create your .venv
- Activate .venv
- Install the required dependencies using requirements.txt.
If Zookeeper and Kafka are not already running, you'll need to restart them. See instructions at [SETUP-KAFKA.md] to:
In VS Code, open a terminal. Use the commands below to activate .venv, and start the producer.
Windows:
.venv\Scripts\activate
py -m producers.json_producer_case
Mac/Linux:
source .venv/bin/activate
python3 -m producers.json_producer_case
What did we name the topic used with JSON data? Hint: See the producer code and .env.
Consumers process streaming data in real time.
In VS Code, open a NEW terminal in your root project folder. Use the commands below to activate .venv, and start the consumer.
Windows:
.venv\Scripts\activate
py -m consumers.json_consumer_case
Mac/Linux:
source .venv/bin/activate
python3 -m consumers.json_consumer_case
What did we name the topic used with JSON data? Hint: See the consumer code and .env.
Follow a similar process to start the csv producer. You will need to:
- Open a new terminal.
- Activate your .venv.
- Know the command that works on your machine to execute python (e.g. py or python3).
- Know how to use the -m (module flag to run your file as a module).
- Know the full name of the module you want to run. Hint: Look in the producers folder.
What did we name the topic used with csv data? Hint: See the producer code and .env.
Follow a similar process to start the csv consumer. You will need to:
- Open a new terminal.
- Activate your .venv.
- Know the command that works on your machine to execute python (e.g. py or python3).
- Know how to use the -m (module flag to run your file as a module).
- Know the full name of the module you want to run. Hint: Look in the consumers folder.
What did we name the topic used with csv data? Hint: See the consumer code and .env.
A food stall occurs when the internal temperature of food plateaus or stops rising during slow cooking, typically between 150°F and 170°F. This happens due to evaporative cooling as moisture escapes from the surface of the food. The plateau can last for hours, requiring adjustments like wrapping the food or raising the cooking temperature to overcome it. Cooking should continue until the food reaches the appropriate internal temperature for safe and proper doneness.
The producer simulates a smart food thermometer, sending a temperature reading every 15 seconds. The consumer monitors these messages and maintains a time window of the last 5 readings. If the temperature varies by less than 2 degrees, the consumer alerts the BBQ master that a stall has been detected. This time window helps capture recent trends while filtering out minor fluctuations.
When resuming work on this project:
- Open the folder in VS Code.
- Start the Zookeeper service.
- Start the Kafka service.
- Activate your local project virtual environment (.env).
To save disk space, you can delete the .venv folder when not actively working on this project. You can always recreate it, activate it, and reinstall the necessary packages later. Managing Python virtual environments is a valuable skill.
This project is licensed under the MIT License as an example project. You are encouraged to fork, copy, explore, and modify the code as you like. See the LICENSE file for more.