Properties props = new Properties(); props.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092"); try (AdminClient client = AdminClient.create(props)) { ListTopicsOptions options = new ListTopicsOptions(); options.listInternal(true); // includes internal topics such as __consumer_offsets ListTopicsResult topics = client.listTopics(options); Set<String> currentTopicList = topics.names().get(); System.out.println("currentTopicList ------"+currentTopicList); }catch(Exception e) { e.printStackTrace(); }
Friday, 18 June 2021
Java Code to check Kafka Topic Exist or Not
Subscribe to:
Comments (Atom)
Java I/O Tutorial