Manage Kafka Topics Using Topic CLI command.

Here we will go through Kafka Topic CLI command to Create and Describe topics. Make sure Apache Kafka and Zookeeper is running before we start using CLI command. If you are new to Apache Kafka, Please go through Kafka Introduction, Kafka installation and Understanding Kafka article before you start CLI command.

Kafka Topic CLI command

Kafka topic CLI command (kafka-topic) is used for managing Kafka topic. Which providers multiple options (create, describe etc) for topic management.

Create Kafka Topic

Kafka topic CLI provides –create option for creating topic. We need to specify replication factor and partition count at the of topic creation with zookeeper host / port as follows:

kafka-topic –zookeeper localhost:2181 –topic mytopic –create –partitions 3 –replication-factor 1

Describe Topic

We can retrieve information about partition / replication factor of Topic using –describe option of Kafka-topic CLI command.

kafka-topic –zookeeper localhost:2181 –topic mytopic –describe

List all topics

–list option used for retrieving all topic names from Apache kafka.

kafka-topic –zookeeper localhost:2181 –list

Delete topic

–delete option used for deleting topic from Apache Kafka.

kafka-topic –zookeeper localhost:2181 –topic mytopic –delete


Hope you are clear about basic topic management command using Kafka-topic CLI. Time to use Kafka Producer & Consumer console application for understanding message delivery. Please go through my next article Kafka consume and produce messages using Kafka CLI command  for better understanding.

Sorry, the comment form is closed at this time.