Kafka Producer JAVA code
In the last post What is Apache Kafka , we discuss Kafka producer, Topics and Consumers. In this post, I am going to provide JAVA code for writing Kafka Producer and explain how it works. In this code, we are going to send data from CSV row by row to Kafka Topics for further consumption by Kafka Consumer . In this way, we can generate the continuous streams of Data. 1. First, you need to create a Kafka Topic. You can either do it from the console or do programmatically. Please go through the basic Quickstart from Apache Kafka Website and create Topics, send basic message from producer and consume it at consumer. Once, you have created Topic, its time to write Kafka Producer, which will send data to Topic. For creating Procuder we need to configure it some parameters. Lets, look at the configurations required for creating producer 1. List of Kafka Brokers 2. Serializer used for sending data to Kafka 3. Acknowledge from Kafka that messages are properly received.