Skip to content

Instantly share code, notes, and snippets.

@diegopacheco
Last active January 24, 2024 03:17
Show Gist options
  • Select an option

  • Save diegopacheco/ff854850816da3110371c98149cc8e0a to your computer and use it in GitHub Desktop.

Select an option

Save diegopacheco/ff854850816da3110371c98149cc8e0a to your computer and use it in GitHub Desktop.
Kaf: Kafka CLI

Install Kaf

curl https://raw.githubusercontent.com/infinimesh/kaf/master/godownloader.sh | BINDIR=$HOME/bin bash
kaf config add-cluster local -b localhost:9092
kaf config select-cluster

Start Zookeper and Kafka

bin/zookeeper-server-start.sh config/zookeeper.properties
bin/kafka-server-start.sh config/server.properties

Create Topic

sudo bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test

Use Kaf

 kaf node ls
ID    ADDRESS       
0     4winds:9092
kaf topics
NAME   PARTITIONS   REPLICAS   
test   1            1   
kaf topics describe test
NAME   PARTITIONS   REPLICAS   
test   1            1  
 echo "works" | kaf produce test
 echo "{\"values:\": [1,2,3,4,5,6]}" | kaf produce test
kaf consume test
works

{
  "values:": [
    1,
    2,
    3,
    4,
    5,
    6
  ]
}
@diegopacheco
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment