I am using kafka 0.8
version and very much new to it.
I want to know the list of topics created in kafka server
along with it\'s
metadata.
If you want to pull broker or other-kafka information from Zookeeper then kafka.utils.ZkUtils
provides a nice interface. Here is the code I have to list all zookeeper brokers (there are a ton of other methods there):
List listBrokers() {
final ZkConnection zkConnection = new ZkConnection(connectionString);
final int sessionTimeoutMs = 10 * 1000;
final int connectionTimeoutMs = 20 * 1000;
final ZkClient zkClient = new ZkClient(connectionString,
sessionTimeoutMs,
connectionTimeoutMs,
ZKStringSerializer$.MODULE$);
final ZkUtils zkUtils = new ZkUtils(zkClient, zkConnection, false);
scala.collection.JavaConversions.seqAsJavaList(zkUtils.getAllBrokersInCluster());
}