install apache kafka on windows 10


Install apache kafka on windows 10 tutorial shows step by step how to install apache kafka on wirdows 10.

Download and install Apache Kafka

First of all, you should download the compressed version of kafka from the kafka website.

In fact, you should already have the JDK installed.

Then, you should put the zipped version of apache Kafka at the root of C:\ drive. This avoids the error that says command is too long.

Now, you should uncompress it using this command :

tar -xzf <kafka tarball>

Startup Apache Kafka

Before starting apache kafka, you should startup the Zookeeper using this command :

bin/windows/zookeeper-server-start.bat config/zookeeper.properties

Then, you can start the kafka server using this command :

bin/windows/kafka-server-start.bat config/server.properties

In order to allow the Kafka server to connect to the zookeeper, you should change these parameters in the kafka server configuration file.

In the server.properties in the config folder, you should make these modifications :

zookeeper.connection.timeout.ms=60000
#broker.id=0

Creating and visualising Apache Kafka topics

Creating apache kafka topic

In order to create an apache Kafka topic, you should run this command :

bin/windows/kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test

This command creates a topic called test that we will use to send and receive messages.

Visualizing apache kafka topic

We can visualize apache kafka topic using this command :

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

Producing and consuming messages using Apache Kafka

Before launching the kafka producer and consumer programs, we should make sure that both the zookeeper and the kafka server are up and running.

Producing messages

To launch the kafka console producer executable, we should run this command :

bin/windows/kafka-console-producer.bat --broker-list localhost:9092 --topic test

This command sends the data entered in the console to the kafka server. So that, the receiver program listening to the test topic will receive it.

Consuming messages

In order to receive the data from the test topic, we should run this command :

bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning

Stopping Apache Kafka server and the zookeeper

We shouldn’t stop apache kafka server and the zookeeper using CTRL + C command because we may cause a data corruption.

To stop the kafka server, we should run this command :
bin/windows/kafka-server-stop.bat

In order to stop the zookeeper, we should run this command :

bin/windows/zookeeper-server-stop.bat

Conclusion

This install apache kafka on windows 10 tutorial arrives at its end.

You may check also our core java tutorial to learn core java from scratch. Please keep tuned because we will release more tutorials about apache kafka and java microservices.

In order to get our latest updates, please feel free to like our how to program facebook page.


Post a Comment

Previous Post Next Post