Basic Kafka Producer, How to write records in Java
You will learn
- How to configure Kafka Consumer properties
- How to create Kafka consumer
- How to send records with Kafka Consumer
The first example shows how to print out records from Kafka to the console.
We will have to set the properties for a Kafka Consumer Object and create it.
Then we subscribe to the topics of our choice
Setting Properties
Properties props = new Properties(); |
Create an Instance of a Kafka Producer, with the properties we just set
Producer |
Cal the send() function on the producer object to send a record to the Kafka topic wetter
for (int i = 0; i < 100; i++) {
producer.send(new ProducerRecord } |