Skip to content

TanjinAlam/python-fastapi-kafka

Repository files navigation

Kafka With Python

Setup

    # Compose up
    $ docker-compose up -d

    # Getinto kafka bash
    $ docker exec -it kafka bash

    # Create a topic with name quickstart
    $ kafka-topics --bootstrap-server kafka:9092  --create  --topic quickstart

    # list topics
    $ kafka-topics --list --bootstrap-server kafka:9092

Write messages to the topic

    # Getinto kafka bash
    $ docker exec -it kafka bash

    # produce some message
    $ kafka-console-producer --bootstrap-server kafka:9092  --topic quickstart
    > this is my first kafka message
    > hello world!
    > this is my second kafka message.

    # When you’ve finished, press Ctrl-D to return to your command prompt.

Read messages from the topic

    # Getinto kafka bash
    $ docker exec -it kafka bash

    # consume some message
    $ kafka-console-consumer --bootstrap-server kafka:9092  --topic quickstart --from-beginning

    # When you’ve finished, press Ctrl-C to return to your command prompt.

Stop the Kafka broker

    # Stop containers
    $ docker-compose down

About

Python, FastAPI, and Kafka integration for high-performance, asynchronous applications with real-time messaging.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors