How to create Avro Kafka Consumer


In the earlier post, we created an Avro producer that sends stock data objects to a Kafka broker. In this post, we will create a consumer that reads those stock data objects and prints the content on the console.For the sake of simplicity, we will not perform any processing on the received messages but merely print them at the console. However, instead of simply writing them on the console, you can implement necessary processing logic depending upon your use case.
This example is an excerpt from the Book Kafka Streams – Real-time Stream Processing
For a detailed explanation of the example and much more, you can get access to the Book using below link.


Solution – Avro Consumer

Creating a Kafka consumer is a four-step process, and it is very similar to creating a Kafka producer. Code Listing below shows the necessary code snippet.


You can access fully function project in our GitHub folder.
A typical consumer will process the records that are returned by the poll() and poll() again for more data. This infinite loop of polling and processing is the fundamental nature of a real-time stream processing application. A typical real-time application is an always running application that keeps pooling the Kafka broker for new records and processes them as they arrive.

Read More

Author : Prashant Pandey -



You will also like:


Streaming Concepts

Let us look at the area concerning the collection and processing of big data streams.

Learning Journal

Artificial Intelligence and Machine Learning

With AI and Machine Learning evolving day by day, let us stay updated with the technology.

Learning Journal

First Class Functions

Function is a first-class citizen in functional programming. What does it mean?

Learning Journal

Kafka Streams : Real-time Stream Processing

This book helps you understand the stream processing in general and apply that skill to Kafka streams programming.

Learning Journal

Why Messaging System

The main idea of a messaging system, and why and how Kafka implements the same notion.

Learning Journal

Referential Transparency

Referential Transparency is an easy method to verify the purity of a function.

Learning Journal