![](/img/trans.png)
[英]Is there a way to query the replication factor and retention time for a topic using the Confluent.Kafka .Net client?
[英]How can we get Replication Factor and Retention Hours of the Topic using Apache Kafka API
我們如何使用Apache Kafka API獲取主題的復制因子和保留時間?
我使用的是0.9版本,並計算了如何使用AdminUtils來獲取數量。
如果你已經熟悉了AdminUtils,那就沒那么遠了。 獲取您感興趣的主題的配置。您將獲得包含此主題的所有配置項的地圖。 至少在kafka 0.8.x中,保留配置的關鍵是“retention.ms”。 所以讓我們試試這個(免責聲明 - 這是未經檢查的代碼):
val zkUtils = ZkUtils(zkConnectionString,
30000,
30000,
JaasUtils.isZkSecurityEnabled())
val configs = AdminUtils.fetchEntityConfig(zkUtils, ConfigType.Topic, topicName)
val retention = configs("retention.ms")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.