One of Kafka new change in the upgrade from 2.3.0 to 2.5.0 is removing ZkUtils (see https://issues.apache.org/jira/browse/KAFKA-8545)
what is the best practice to remove the use and which package should I use instead
public void createTopic(String topicName, int partitions, int replicationFactor) {
DataExportConfig conf = ApplicationContextProvider.getApplicationContext().getBean("dataExportConfig", DataExportConfig.class);
String zKaddress = conf.getZkHost();
boolean isSecureKafkaCluster = false;
ZkUtils zkUtils ZkUtils.apply(zKaddress, zkSessionTimeoutMs, zkConnectionTimeOutInMs, isSecureKafkaCluster);
try {
if (!AdminUtils.topicExists(zkUtils, topicName)) {
AdminUtils.createTopic(zkUtils, topicName, partitions, replicationFactor, new Properties(), RackAwareMode.Enforced$.MODULE$);
//log
} else {
//log
}
List<String> topicList = Arrays.asList(topicName);
// checking real partition size for topic
Integer topicPartitionSizeInZooKeeper = JavaConversions.mapAsJavaMap(zkUtils.getPartitionAssignmentForTopics(JavaConversions.asScalaBuffer(topicList))).get(topicName).size();
if (topicPartitionSizeInZooKeeper != partitions) {
//log
} catch (Exception ex) {
//log
throw ex;
} finally {
//close zookeeper client after all topics are created
zkUtils.zkClient().close();
}
}