Kafka Topic CLI commands

Kafka-Topic Shristi Singh

What is Kafka-Topic?

Apache Kafka is a real time-event driven platform, a distributed streaming platform. Where Topics are streams of related messages in Kafka. It is a logical representation of categorized messages into groups.

Producers writes to Kafka platform & it responds with acknowledgement or negative acknowledgement.

Brokers are local storage which stores the data of producers into pages(Basically, are servers). Kafka keeps clusters of brokers.

Consumers ask/trigger Kafka brokers continuously asking for data if available, called as polling.

  • Developers define Topics.
  • Producer → Topic is a N → N relationship. One can create unimitated number of topics.
  • Topics are sub-categorized into Partitions & further into Segments.

Kafka-Topic CLI Commands:

To List out all the commands associated with kafka, to Create, delete, describe, or change a topic can be listed out by executing ‘kafka-topics’ batch file.

D:\kafka_2.12–2.5.0\bin\windows>kafka-topics.bat

Further demonstrating each command and it’s functioning:

  1. Create a topic:

D:\kafka_2.12–2.5.0\bin\windows>kafka-topics.bat — zookeeper localhost:2181 — topic <topic_name> — create — partitions <number_of_partitions> — replication-factor <total_replicas>example: kafka-topics.bat — zookeeper localhost:2181 — topic mytopic — create — partitions 3 — replication-factor 1

output:

Created topic mytopic.

2. Describe a topic:

D:\kafka_2.12–2.5.0\bin\windows>kafka-topics.bat — zookeeper localhost:2181 — topic <topic_name> — describeexample: kafka-topics.bat — zookeeper localhost:2181 — topic mytopic — describe

output:

Topic: mytopic PartitionCount: 3 ReplicationFactor: 1 Configs:

Topic: mytopic Partition: 0 Leader: 0 Replicas: 0 Isr: 0

Topic: mytopic Partition: 1 Leader: 0 Replicas: 0 Isr: 0

Topic: mytopic Partition: 2 Leader: 0 Replicas: 0 Isr: 0

3. List all the topic in the cluster:

D:\kafka_2.12–2.5.0\bin\windows>kafka-topics.bat — zookeeper localhost:2181 — list

output:

mytopic

4. Delete a topic:

D:\kafka_2.12–2.5.0\bin\windows>kafka-topics.bat — zookeeper localhost:2181 — topic <topic_name> — deleteexample: kafka-topics.bat — zookeeper localhost:2181 — topic mytopic — delete

output:

Topic mytopic is marked for deletion.

Note: This will have no impact if delete.topic.enable is not set to true.

SAMPLE:

That’s it! Don’t look any further.

--

--

--

Full-stack Java Developer by profession, Blogger & Artist by choice.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Why It’s Crucial to Have DesignOps

district0x Dev Update - May 26th, 2020

HACK + ALT + NCOMMANDER TXT :: Windows for Workgroups

Why you should learn to code now!

Project Management methodologies in a shortcut

Tableau — Merge Rows to Columns with a Delimiter

How to set up a Redis Cluster with TLS in a local machine

How to set up a Redis Cluster with TLS in a local machine

CSS: select first-of-class with the subsequent sibling combinator

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Shristi Singh

Shristi Singh

Full-stack Java Developer by profession, Blogger & Artist by choice.

More from Medium

LOB Migration in PostgreSQL

Run a Spring boot docker image on windows with a MySQL local database connection

What exactly is Apache Maven?

ELK Architecture Part-1