Wednesday, March 16, 2016

How can we get Replication Factor and Retention Hours of the Topic using Apache Kafka API

Leave a Comment

How can we get Replication Factor and Retention Hours of the Topic using Apache Kafka API?

I am using version 0.9 and figured how to use AdminUtils to get number of paritiions.

1 Answers

Answers 1

If you are already familiar with the the AdminUtils it's not that far to go. Get the config of the topic you are interest in. You'll get a map with all configuration items of this topic. At least in kafka 0.8.x the key for the retention configuration was "retention.ms". So let's try this one (Disclaimer - This is unchecked code):

val zkUtils = ZkUtils(zkConnectionString,                       30000,                       30000,                       JaasUtils.isZkSecurityEnabled()) val configs = AdminUtils.fetchEntityConfig(zkUtils, ConfigType.Topic, topicName) val retention = configs("retention.ms") 
If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment