Partition and Replication Factor.

How to create Topics with Partitions & Replication factor using Kafka?

Please make sure that you have started the server. Learn How to start the server in Kafka?

Producers write data to topics and consumers read from topics.

Since Kafka is a distributed system, topics are partitioned and replicated across multiple nodes. Kafka treats each topic partition as a log (an ordered set of messages). Each message in a partition is assigned a unique offset.

Each topic has a user-defined category (or feed name), to which messages are published.

Create a Topic

To create a Kafka topic, run kafka-topics.bat (windows) or kafka-topics.sh (Mac or Linux) and specify the topic name, replication factor, and other attributes:

The following example creates a topic named “test-topic”, with 4 partitions and 1 replica:

.\bin\windows\kafka-topics.bat --create --topic test-topic -zookeeper localhost:2181 --replication-factor 1 --partitions 4
test-topic is created

View or List all the Topics

To view the topic, run the list topic command:

.\bin\windows\kafka-topics.bat --list --zookeeper localhost:2181

-> you can see Topic is listed with the name “test-topic

The auto.create.topics.enable property, when set to true, automatically creates topics when applications attempt to produce, consume, or fetch metadata for a nonexistent topic.

Kafka Tutorials

Next →

Previous ←

I am Full Stack Java Developer @ Tata Strive | Get blogs and tutorials related to the (React | Kafka | DevOps) | Follow me on LinkedIn https://www.linkedin.com

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

Recommended from Medium

Q&A with a rideOS Intern: Hari Kothapalli

Something Someone Somewhere Uses… Sometimes

Creating Slowly App UI with Flutter (Part 2)

Microsoft SQL — How to Compare Schema of Same Table In Two Different Servers

Finding locators in selenium

Cart Discounts in commercetools

Dev C++ Bloodshed Auto Insert Code At Beginning Of File

Kotlin Multiplatform (KMP) ~ KMP01

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
Sagar Kudu

Sagar Kudu

I am Full Stack Java Developer @ Tata Strive | Get blogs and tutorials related to the (React | Kafka | DevOps) | Follow me on LinkedIn https://www.linkedin.com

More from Medium

How to Dockerize Spring Boot Application

Deploy java/spring application with mysql DB on Kubernetes

Elasticsearch Search API: Are You Getting CORS?

Kafka for dummies and with practical failure experiments