Let's download Kafka from https://kafka.apache.org/downloads and untar it using the following commands:
> tar -xzf kafka_2.12-1.1.0.tgz
> cd kafka_2.12-1.1.0
Let's start ZooKeeper and Kafka on Windows:
> binwindowszookeeper-server-start.bat configzookeeper.properties
> binwindowskafka-server-start.bat configserver.properties
You can start ZooKeeper and Kafka on Linux by using the following commands:
> bin/zookeeper-server-start.sh config/zookeeper.properties
> bin/kafka-server-start.sh config/server.properties
After starting Kafka on your machine, let's add the Kafka Maven dependency in your application:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-kafka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-kafka-streams</artifactId>
</dependency>
As you can see, we have added Spring Cloud Stream and Kafka binder. After adding these dependencies, let's configure the configuration properties for Kafka.