【发布时间】:2020-09-29 06:25:12
【问题描述】:
我目前正在使用 kafka-python==2.0.1,
from kafka import KafkaAdminClient
from kafka.admin import NewTopic
topic_name = "retention_test"
admin = KafkaAdminClient(bootstrap_servers=['localhost:9092'])
topic = NewTopic(name=topic_name, num_partitions=1, replication_factor=3, topic_configs={'log.retention.hours' : '100'})
response = admin.create_topics([topic])
print(response)
但无法创建主题,并抛出以下错误 -
raise error_type(
kafka.errors.InvalidConfigurationError: [Error 40] InvalidConfigurationError: Request 'CreateTopicsRequest_v3(create_topic_requests=[(topic='retention_test', num_partitions=1, replication_factor=3, replica_assignment=[], configs=[(config_key='log.retention.hours', config_value=100)])], timeout=30000, validate_only=False)' failed with response 'CreateTopicsResponse_v3(throttle_time_ms=0, topic_errors=[(topic='retention_test', error_code=40, error_message='Unknown topic config name: log.retention.hours')])
【问题讨论】:
标签: python apache-kafka kafka-python