An open API service indexing awesome lists of open source software.

https://github.com/emanahmed55/weather-forecaster

A simple project of kafka and python to demonstrate basic concepts of producer, consumer and topic
https://github.com/emanahmed55/weather-forecaster

consumer kafka producer python topic weather

Last synced: 3 months ago
JSON representation

A simple project of kafka and python to demonstrate basic concepts of producer, consumer and topic

Awesome Lists containing this project

README

          

# Weather Forecaster

A simple project of kafka and python to demonstrate basic concepts of producer, consumer and topic

## Table of Contents

- [Installation](#installation)
- [Main idea of the project](#usage)
- [How to run the project](#contributing)

## Installation

To run this project, you need to have the JDK of java and following Python packages installed:


  • matplotlib

  • kafka-python

You can install these packages using pip:


pip install matplotlib kafka-python

## Usage



  1. Producer

    It generates random weather data , including weatherstate , temperature and humidity.It sends this data as messages to kafka.


  2. Topic

    This is where the weather data gets snt.It receives weather data messages from the producer and makes them available for consumers.


  3. Consumer

    It fetches data from kafka topic and displays them in a real-time graph or chart.

## How to run the project

Steps to run the project:



  1. Install kafka

    Extract the folder and copy the folder at any place ( here in D Partition)
    Go to kakafolder \config\server.properties.
    Edit log.dirs=D:/kafkafoldername/kafka-logs.
    Go to kafkafoldername\config\zookeeper.properties
    Edit dataDir=D:/kafkafoldername/zookeeper-data



  2. Start zookeeper server

    Go to kafkafoldername\bin\windows and Open command propmpt and write "D:\kafka_2.12-3.7.0\bin\windows\zookeeper-server-start.bat D:\kafka_2.12-3.7.0\config\zookeeper.properties"
    Don't close the cmd window


  3. Start kafka server in another new CMD window at the same previous path

    Write "D:\kafka_2.12-3.7.0\bin\windows\kafka-server-start.bat D:\kafka_2.12-3.7.0\config\server.properties"
    Don't close this CMD window


  4. Create a kafka topic in another new CMD window at the same previous path

    Write "kafka-topics.bat --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic weather_forecasts"
    Don't close this CMD window


  5. Create a kafka producer in the same previous CMD window at the same previous path

    Write "kafka-console-producer.bat --broker-list localhost:9092 --topic weather_forecasts"
    Don't close this CMD window


  6. Create a kafka consumer in another new CMD window at the same previous path

    Write "kafka-console-consumer.bat --topic weather_forecasts --bootstrap-server localhost:9092 --from-beginning D:\kafka_2.12-3.7.0\data\kafka"
    Don't close this CMD window


  7. GO To visual studio code and run producer.py



  8. GO To visual studio code and run consumer.py in another terminal



  9. To stop the project

    Go to the opened zookeeper server CMD window and write "D:\kafka_2.12-3.7.0\bin\windows\zookeeper-server-stop.bat D:\kafka_2.12-3.7.0\config\zookeeper.properties" Then Go to the opened kafka server CMD window and write "D:\kafka_2.12-3.7.0\bin\windows\kafka-server-stop.bat D:\kafka_2.12-3.7.0\config\server.properties"