A Simple Implementation of Spring Kafka + Spring Boot

Kafka is heavily used for event streaming

Ruby Valappil
Javarevisited

--

Apache Kafka is an event streaming platform where data flows from one system to another. Its use cases are but are not limited to, IoT, real-time data analytics, log aggregation and analysis, message broker, and so on.

In this article, we will learn how apache Kafka is used as a message broker. The role of a message broker is to pass data from one system or service to another system or service.

As microservices became popular in the software industry, Kafka became a useful tool to make asynchronous communication possible.

How Kafka works as a message broker is shown in the image below.

Simple representation of Apache Kafka as Message Broker

Spring Kafka is Spring’s implementation of adding an abstraction over Kafka java client. It comes with a template and message-driven POJOs, we will learn more about that in the implementation section.

To implement Spring Kafka, we would first need to set up Kafka in our local machine.

Few terms to remember

Producer-Consumer: Producer is the application that would write data to the Kafka topics and Consumer is the application that would read the data.

--

--