【问题标题】:How can I configure a Spring Cloud Stream (Kafka) application to autocreate the topics in Confluent Cloud?如何配置 Spring Cloud Stream (Kafka) 应用程序以在 Confluent Cloud 中自动创建主题?
【发布时间】:2020-04-19 06:33:00
【问题描述】:

有没有办法让(Spring Cloud Stream)应用程序在 Confluent Cloud 中自动创建他们需要的主题?

到目前为止,我不得不手动创建它们,当您认为您还必须设置更改日志主题时,这很容易出错。

【问题讨论】:

    标签: apache-kafka spring-cloud-stream spring-cloud-stream-binder-kafka


    【解决方案1】:

    活页夹属性autoCreateTopicstrue by default。因此应该自动创建主题(除非代理权限不允许这样做 - 但我希望在这种情况下会在日志中看到错误)。

    还有一个属性autoAddPartitions默认为false。

    【讨论】:

    • 嗨 Gary,显然 Confluent Cloud 似乎阻止了主题的自动创建,这就是日志中显示的内容:Error while fetching metadata with correlation id 5 : {info-topic=UNKNOWN_TOPIC_OR_PARTITION}
    • 我建议您在调试器中运行并在KafkaTopicProvisioner.createTopicAndPartitions 中设置断点并单步执行代码。它使用AdminClient 到第一个listTopics(),如果主题不存在,则使用createTopics() 添加它。如果失败,它会记录一个异常。
    • 你完全正确。在某些时候,我禁用了自动创建,删除它后出现以下错误:org.apache.kafka.common.errors.PolicyViolationException: Topic replication factor must be 3。我必须设置spring.cloud.stream.kafka.binder.replication-factor=3。也适用于变更日志主题:spring.cloud.stream.kafka.streams.binder.configuration.replication.factor=3
    猜你喜欢
    • 2022-12-10
    • 2017-03-22
    • 1970-01-01
    • 2018-06-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-09
    相关资源
    最近更新 更多