Skip to content

dfesalbon-python/fast-api-kafka

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Kafka

Pre-requisite

  • Installed Docker on your computer
  • Python installed with necessary packages (python kafka, fast-api, etc.)
  • Git installed on your computer
  • Postman installed on your computer
  • Knowledge in REST APIs and HTTP requests

Instructions

Clone the repository https://github.com/python-realm/fast-api-kafka.git:

git clone https://github.com/python-realm/fast-api-kafka.git

Open a terminal inside the repository folder and execute 'docker compose up' to pull the zookeeper and kafka images and run the container:

docker compose up

Before proceeding to the next step make sure the containers are running.

Open new terminal inside the repository folder and run:

python main.py

This will run the main FAST API service on localhost:8000.

Open new terminal inside the repository folder and run:

python receive.py

Check both of the terminals. On terminal where main.py is executed, you will see some logs like this:

INFO:     Started server process [8524]
INFO:     Waiting for application startup.
INFO:     Application startup complete.   
INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)

On terminal where received.py is executed, you will see some logs like this:

started listening..

Open a postman and send a POST request on http://127.0.0.1:8000 with request body:

{
    "id":"123",
    "first_name": "Juan",
    "last_name": "Dela Cruz"
}

Check the request response and the logs on the terminal where receive.py is executed.

You now have a working FAST API kafka messaging service. :)

About

Sample implementation of Kafka in Python FAST API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages