How to setup Kafka on Windows

Source: Apache Kafka Quickstart

Step 1: Download the code by going to: Apache Kafka Website. Extract kafka_2.11-0.11.0.0.tgz to desired location.

Step 2:  Start Zookeeper and Kafka Server

To start Zookeeper on windows use command:
D:\Programs\Apache\kafka_2.11-0.11.0.0>bin\windows\zookeeper-server-start.bat config\zookeeper.properties

To start Kafka server on windows use command:
D:\Programs\Apache\kafka_2.11-0.11.0.0>bin\windows\kafka-server-start.bat config/server.properties

Step 3: Create a topic on Kafka by using the command:
D:\Programs\Apache\kafka_2.11-0.11.0.0>bin\windows\kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test

Run list topic command to see the topic created:
D:\Programs\Apache\kafka_2.11-0.11.0.0>bin\windows\kafka-topics.bat --list --zookeeper localhost:2181
test

Step 4: Run the producer and send some messages on topic: test
D:\Programs\Apache\kafka_2.11-0.11.0.0>bin\windows\kafka-console-producer.bat --broker-list localhost:9092 --topic test
Test message 1
Test message 2

Step 5: Run the consumer and check the messages that were sent from the producer on topic: test
D:\Programs\Apache\kafka_2.11-0.11.0.0>bin\windows\kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test --from-beginning
Test message 1
Test message 2

Comments

Popular Posts

REST API using Play Framework with Java

Asynchronous Processing (@Async) in Spring Boot

Elasticsearch, Logstash, Kibana Tutorial: Load MySQL Data into Elasticsearch