Adding or removing topics
The first chapters explained how to create a topic. The power behind the tool is that it can add topics programmatically or manually, and can enable the Kafka option to automatically add topics. In production, it is recommended that you disable automatic topic creation to eliminate programming errors where data is accidentally pushed to a topic that it didn't mean to create at the beginning.
Getting ready
For this recipe, Kafka must be installed, ZooKeeper should be running, and the broker should be running with some topics created on it.
How to do it...
- Go to the Kafka installation directory and create a topic called
test-topic
:
$ bin/kafka-topics.sh --create --zookeeper localhost:2181 --topic test-topic --partitions 5 --replication-factor 2
The output should be as follows:
Created topic "test-topic".
- Describe the
test-topic
topic with the following command:
$ bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic test-topic
The output should be as follows:
topic...