How to Create and Describe a Kafka topic

  • Post author:

This article describes how to create Apache Kafka topic and explains how to describe newly created and list all existing topics in Kafka. Producers publish and consumer receives messages to/from topics

Related: Ways to Delete messages from Kafka topic

1. Create Kafka Topic

All massages to and from Apache Kafka will happen via topics. Kafka by default creates a topic when we send a message to a non existing topic. This defines at $KAFKA_HOME/conf/ properties file with auto.create.topics.enable is set to true (by default),

To create a Apache Kafka topic by command, run and specify topic name, replication factor, and other attributes. Producers write data to topics and consumers read from topics.

bin/ --zookeeper localhost:2181 \
                --create \
                --topic text_topic \
                --replication-factor 1 --partitions 1

This will create a topic “text_topic” with replication factor 1 and partition 1.

2. Describe Kafka Topic

Describes newly created topic by running following command with option .–describe –topic This command returns leader broker id, replication factor and partition details of the topic.

bin/ --zookeeper localhost:2181 \
                --describe --topic text_topic
Apache Kafka Topic

3. Describe All Topics

Option –describe returns description of all existing topics

bin/ --zookeeper localhost:2181 \

4. List All Topics

Option –list returns all topics present in Kafka

bin/ --zookeeper localhost:2181 --list


In this article, you have learned how to create a Kafka topic and describe all and a specific topic using

NNK is a Big Data and Spark examples community page, all examples are simple and easy to understand and well tested in our development environment Read more ..

Leave a Reply