Editor’s note: The post was origially published in December 2013 and has been updated to reflect the changes to Apache Kafka from 0.8.0 to 3.4.0

Introduction

Kafka is a distributed messaging system developed by LinkedIn and later donated to Apache as an open source project. The main purpose of creating Kafka was collecting and delivering high volume of log data with low latency.

Below are the steps we will follow for Windows operating system.

  1. Download Apache Kafka version 3.4.0 from here
  2. Install Java 8 in your Windows OS
  3. Configure Zookeeper and Kafka bootstrap server
  4. Verify the producer and consumer communication

Configure Apache Kafka environment

  1. Unzip the Kafka distribution to a folder of your choice e.g. C:\git\kafka_2.12-3.4.0. All commands will be executed from the root folder of Apache Kafka distribution
  2. Ensure you have the Java environment configured using java -version. Below is the expected output.
    C:\git\kafka_2.12-3.4.0> java -version
       
    openjdk version "1.8.0_362"
    OpenJDK Runtime Environment Corretto-8.362.08.1 (build 1.8.0_362-b08)
    OpenJDK 64-Bit Server VM Corretto-8.362.08.1 (build 25.362-b08, mixed mode)
    
  3. Open the command line terminal and start the Zookeeper instance
    C:\git\kafka_2.12-3.4.0> bin\windows\zookeeper-server-start.bat config\zookeeper.properties
    
  4. Open the another command line terminal and start the Zookeeper instance
    C:\git\kafka_2.12-3.4.0> bin\windows\kafka-server-start.bat config\server.properties
    

Verify the installation

  1. Creating a topic
    C:\git\kafka_2.12-3.4.0> bin\windows\kafka-topics.bat --create --topic demo-events --bootstrap-server localhost:9092
       
    Created topic demo-events
    
  2. Sending a message via producer
    C:\git\kafka_2.12-3.4.0> bin\windows\kafka-console-producer.bat --topic demo-events --sync --bootstrap-server localhost:9092
    
  3. Receiving a message via consumer
    C:\git\kafka_2.12-3.4.0> bin\windows\kafka-console-consumer.bat --topic demo-events --bootstrap-server localhost:9092 --from-beginning
    
  4. Any messages typed out in the producer terminal will be replicated by the brokers and displayed in the consumer terminal
  5. Kafka logs are stored in C:\tmp\kafka-logs and Zookeeper logs are stored in C:\tmp\zookeeper

References