From the course: Apache Kafka Essential Training: Getting Started (2021)

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Creating a consumer in Java

Creating a consumer in Java

From the course: Apache Kafka Essential Training: Getting Started (2021)

Start my 1-month free trial

Creating a consumer in Java

- [Instructor] In this video, we will build a consumer in Java to consume messages from the kafka.learning.orders topic and print them to the console. The code for this is available in the KafkaSimpleConsumer.java file under the chapter five package. Setting up a consumer is similar to setting up a producer. We first provide a list of Kafka brokers with the bootstrap servers parameter. Then we need to provide deserializers for the messages. Messages received from Kafka are byte arrays, and the Kafka client will call the deserializer to convert the key and value to equivalent Java objects. In addition, we need to specify the consumer group name in the group ID parameter. We use Kafka Cava Consumer as the name. We use the auto offset reset config parameter to specify whether we want all the messages in the topic, or only new messages. In this case, we specify the earliest as we are requesting all messages from the topic.…

Contents