Member-only story
Kafka Producer Example Using Java
In this article, we will see how to produce records/messages with Kafka brokers. Let’s get to it!
In last article, we discussed how to install Apache Kafka using Zookeeper on windows. In this article, we will see how to produce records/messages with Kafka brokers.
Now, before creating a Kafka producer in java, we need to define the essential Project dependencies. In our project, there will be three dependencies required:
So After Generating the project we will extract this. We will import this project into Eclipse.
Here In this project we will create one Rest Endpoint that will be used to publish the message on topic.
So, First we will create KafkaProducerConfig.java class in package com.example.kafkaproducer.config. Here we will define KafkaProducer with some properties.