Apache Kafka Basic Operations

Let’s understand the Apache Kafka Basic Operations one by one,

Basic Operation

Step 1: Start ZooKeeper

Firstly open a terminal and type the below command.

bin/zookeeper-server-start.sh config/zookeeper.properties
Step 2: Start Kafka Broker
bin/kafka-server-start.sh config/server.properties
Step 3: Check the Status of the services

821 QuorumPeerMain

928 Kafka

931 Jps

Step 4: Create Kafka Topic

Open Command line and create topics on the server.

bin/kafka-topics.sh –create –zookeeper localhost:**** –replication-factor 1

–partitions 1 –topic Hi-Kafka

Step 5: List of Topics

It will list out the created Topics

$bin/kafka-topics.sh –list –zookeeper localhost:****


Step 6: Start Producer to Send Messages
$bin/kafka-console-producer.sh –broker-list localhost:**** –topic Hi-Kafka

$bin/kafka-console-producer.sh –broker-list localhost:****

–topic Hi-Kafka


My first message

Step 7: Start Consumer to Receive Messages
$bin/kafka-console-consumer.sh –zookeeper localhost:**** —topic Hi-Kafka



My first message

My second message


Step 8: Modifying a Topic

Now modify the Created Topic using below command.

$bin/kafka-topics.sh –zookeeper localhost:****  –alter –topic Hi-kafka –partitions 2

>Adding partitions succeeded!

Step 9: Deleting a Topic

Now delete the previously created topic “Hi-Kafka”

$bin/kafka-topics.sh –zookeeper localhost:**** –delete –topic Hi-kafka

> Topic Hi-kafka marked for deletion

“That’s all about the Basic operation of Kafka, i hope beginners find few knowledge on Apache kafka”