Skip to content

Kafka CLI for admin management, publish and subscribe to Kafka Brokers written in Python

Notifications You must be signed in to change notification settings

wuriyanto48/kafka-cli-py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

kafka-cli-py

Kafka CLI tools written in Python for publish and subscribe message from Apache Kafka.

A similiar tool that i built with Golang https://github.com/musobarlab/kafka-cli.

Install

Manual install

$ git clone https://github.com/wuriyanto48/kafka-cli-py.git
$ pip install -r requirements.txt
$ python setup.py install

Usage

See available options

$ kafka-cli -h

Publish Message to Kafka

$ kafka-cli pub --brokers localhost:9092 --topic topbanget1 --message "hello world"
$ kafka-cli pub --brokers localhost:9092 --topic topbanget1 --message '{"header":"JSON","content":"this is JSON message"}'

Subscribe and get Message from Kafka

$ kafka-cli sub --brokers localhost:9092 --topic topbanget1

Multiple brokers

$ kafka-cli sub --brokers localhost:9092,localhost:9093,localhost:9094 --topic topbanget1

With auth mechanism, you need to provide --auth flag to prompt username and password

$ kafka-cli sub --brokers localhost:9092,localhost:9093,localhost:9094 --topic topbanget1 --auth
$ username: admin
$ password: adminpass

Show all topic

kafka-cli adm list-topic --brokers localhost:9092,localhost:9093,localhost:9094 --auth

Create new topic

$ kafka-cli adm create-topic --brokers localhost:9092,localhost:9093,localhost:9094 --topic topbanget1 --partition 3 --replication 3 --auth

Delete topic

$ kafka-cli adm delete-topic --brokers localhost:9092,localhost:9093,localhost:9094 --topic topic_name_to_delete --auth

Add partition to topic

$ kafka-cli adm add-partition --brokers localhost:9092,localhost:9093,localhost:9094 --topic existing_topic_name --partition 3 --auth

About

Kafka CLI for admin management, publish and subscribe to Kafka Brokers written in Python

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages