Posts

How to create kafka compacted topic

Image
0 I have a Kafka application that has a producer who produces messages to a topic. A consumer then takes the messages from the topic, does some logic to the given messages and then produces them to another topic. I'm using ProducerRecord and ConsumerRecords . I want my app to create 2 compacted topics and then use them. If the compacted topics already exist, just display a message and continue. My SimpleProducer class: package com.kafkatest.demo; import java.util.*; import org.apache.kafka.clients.producer.*; public class SimpleProducer extends Thread{ public static void main(String args) throws Exception{ String topicName = "nodesTopic"; String key = "Key1"; String value = "Value-1"; String key1 = "Key2"; Str...