rawheel / Kafka-Python-Example

A Guide to setup Kafka with Python in less than 5 minutes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Kafka with Python Setup in Less than 5 Minutes

This guide demonstrates a quick setup for working with Kafka and Python using Faust and Docker Compose. You can have Kafka up and running in just a few minutes following these steps.

Step 1: Setting Up Kafka with Docker Compose

  1. Clone the kafka-stack-docker-compose repository:

    git clone https://github.com/conduktor/kafka-stack-docker-compose
    
  2. Navigate to the repository directory:

    cd kafka-stack-docker-compose
  3. Start Kafka and ZooKeeper containers:

    docker compose -f zk-single-kafka-single.yml up
    

Step 2: Running the Python Kafka Setup

  1. Clone this project:

    git clone https://github.com/rawheel/Kafka-Python-Example.git
    
  2. Navigate to the project directory:

    cd Kafka-Python-Example
  3. Install project dependencies:

    pip install -r requirements.txt
  4. Start a Faust worker:

    faust -A worker worker -l info
  5. To produce a Kafka message using the Faust command-line tool, run:

    faust -A worker send hello_world 'Hello Folks, Raheel Here!'
    
  6. To produce kafka messages using python code

    python producer.py

About

A Guide to setup Kafka with Python in less than 5 minutes


Languages

Language:Python 100.0%