[英]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.