- Create topic
bash
/bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --topic $TOPIC_NAME --partitions 1 --replication-factor 1
- Create topic w/ short retention (10 seconds, instead of default 7 days)
bash
/bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --topic $TOPIC_NAME --partitions 1 --replication-factor 1 --config retention.ms=1000 --config segment.ms=1000
- List topics
bash
/bin/kafka-topics.sh --list
- Show partition offsets of topic
bash
/bin/kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list localhost:9092 --topic $TOPIC_NAME
- Consume topic
bash
/bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic $TOPIC_NAME
- Consume topic w/ key value
bash
/bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic $TOPIC_NAME --property print.key=true --property key.separator="-"