Apache Kafka is an open-source stream-processing software platform. We can use Apache Kafka with microservice architecture as a message bus for communication between microservices.
In this article, we will learn how to set up Apache Kafka on Windows system.
Let us begin. 🙂
We need to install Java to set up the Apache Kafka server. If Java is not yet installed in your machine, install it before moving further.
We can check the installed Java version as shown below.
Download Apache Kafka
We can download the latest Apache Kafka zip file from here.
Once the file is downloaded, we can extract the file using 7-zip to any location required. I have extracted the archived file into C:\Kafka directory of my Windows system.
I am using the latest available version of Apache Kafka, which is version:2.3.1
Setup the Zookeeper server
We need the Zookeeper to set up the Apache Kafka server. Zookeeper is a software tool that keeps track of the status of the Kafka cluster nodes and it also keeps track of Kafka topics, partitions, etc.
Apache Kafka archive file contains Zookeeper packaged with it. We are going to use the same.
Let us set up the Zookeeper now.
Open the command prompt. Navigate to the unzipped Kafka directory and navigate inside kafka\bin\windows folder.
Execute the command: zookeeper-server-start.bat ..\..\config\zookeeper.properties. Here, we are starting the Zookeeper server with default property provided under kafka\config\ directory.
Once the Zookeeper fires up, we will be able to see the following message on command prompt.
Congratulations!! 🙂 Zookeeper server is up and running on port 2181.
Set up the Kafka server
Next step is to start the Kafka server.
Open a new command prompt window, navigate to kafka\bin\windows directory.
Execute the command: kafka-server-start.bat ..\..\config\server.properties as shown below.
We should be able to get screen with content similar to below image.
Apache Kafka server starts on 9092 port by default.
Congratulations!! 🙂 Apache Kafka server is up and running on our windows system successfully.
Create a Kafka topic
We can create a simple Kafka topic to verify if our Kafka set up is configured properly.
Open command prompt in a new window, and execute the following command.
kafka-topics.bat –delete –bootstrap-server localhost:9092 –replication-factor 1 –partitions 1 –topic test-topic
We have created a Kafka topic called test-topic.
List the topics
We can list the created Kafka topics with below command.
kafka-topics.sh –list –bootstrap-server localhost:9092
Below image shows the list of Kafka topics created in the kafka server.
In this article we learned how to set up Apache Kafka server on the Windows system.
In the next article, we will learn how to create a spring boot application and configure producer/ consumer configurations for Kafka topics.