This is post is about how to create a Kafka topic dynamically through Java.In one of my project, we(me and my friend Jaya Ananthram) were required to create dynamic Kafka topic through Java. Since there is no documentation on Kafka official documentation we are struggled to create dynamic Kafka topic through Java. Then After a long search ,we found this solution for creating the Kafka topic through Java. import java.util.Properties; import kafka.admin.AdminUtils; import kafka.utils.ZKStringSerializer$; import kafka.utils.ZkUtils; import org.I0Itec.zkclient.ZkClient; import org.I0Itec.zkclient.ZkConnection; public class KafkaTopicCreationInJava { public static void main(String[] args) throws Exception { ZkClient zkClient = null; ZkUtils zkUtils = null; try { String zookeeperHosts = "localhost:2181"; // If multiple zookeeper then -> String zookeeperHosts = "192.168.1.1:2181,192.168.1.2:2181"; ...
I'm a Programmer,that's what I'm