簡體   English   中英

如何描述主題kafka的配置?

[英]How to describe configuration of topic kafka?

我想描述一個主題的配置。 我使用 confluent-kafka-python librairie(版本 1.5.0)開發了一個腳本,我的 python 版本是 2.7。 我的最終目標是能夠將保留時間更改為我的主題 (retention.ms),但為此,我需要提取我的主題的所有配置並更改我想要的內容,並保留其他已定義的內容。

我的腳本:

def describe_topic(admin_client, topic):

resources = [ConfigResource(confluent_kafka.admin.RESOURCE_TOPIC, topic)]
fs = admin_client.describe_configs(resources)
for resource, f in fs.items():
    remote_config = f.result()
    print(remote_config)
    return resource, remote_config

但我有這個錯誤:

錯誤
文件“kafka.py”,第 192 行,在 describe_topic 中
資源 = [配置資源(confluent_kafka.admin.RESOURCE_TOPIC,主題)]
文件“environment/mamba-6Od8R-HF-py2.7/lib/python2.7/site-packages/kafka/admin/config_resource.py”,第 33 行,在init 中
resource_type = ConfigResourceType[str(resource_type).upper()] # pylint: disable-msg=unsubscriptable-object
文件“/product/tedhdev/environment/mamba-6Od8R-HF-py2.7/lib/python2.7/site-packages/enum/初始化的.py”,線路394,在的GetItem
返回 cls。 member_map [名稱]
密鑰錯誤:'2'\\

有人能幫我嗎? 非常感謝

import kafka
from kafka.admin import KafkaAdminClient, ConfigResource, ConfigResourceType

client_conn = kafka.KafkaAdminClient(bootstrap_servers="localhost:9092")
print(client_conn.describe_configs(config_resources=[ConfigResource(ConfigResourceType.TOPIC, "topic")]))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM