【问题标题】:Spring cloud stream (Kafka) autoCreateTopics not working春季云流(Kafka)自动创建主题不起作用
【发布时间】:2021-09-08 22:47:14
【问题描述】:

我正在使用带有 Kafka 活页夹的 Spring Cloud 流。要禁用我提到的自动创建主题 - How can I configure a Spring Cloud Stream (Kafka) application to autocreate the topics in Confluent Cloud?。但是,设置此属性似乎不起作用,框架会自动创建主题。

这是application.properties中的配置

spring.cloud.stream.kafka.binder.auto-create-topics=false

这是启动日志

2021-06-25 09:22:46.522  INFO 38879 --- [pool-2-thread-1] o.a.k.clients.consumer.ConsumerConfig    : ConsumerConfig values: 
    allow.auto.create.topics = true
    auto.commit.interval.ms = 5000
    auto.offset.reset = latest
    bootstrap.servers = [localhost:9092]

其他细节-

  1. Spring Boot 版本:2.3.12.RELEASE
  2. Spring Cloud Stream 版本:Hoxton.SR11

我在这个配置中遗漏了什么吗?

【问题讨论】:

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


    【解决方案1】:

    spring.cloud.stream.kafka.binder.auto-create-topics=false

    该属性配置活页夹,使其不会创建主题;它没有设置消费者属性。

    要显式设置该属性,还要设置

    spring.cloud.stream.kafka.binder.consumer-properties.allow.auto.create.topics=false
    

    【讨论】:

    • 太棒了!这对消费者有用。有没有办法为生产者禁用这个自动创建?我试过 spring.cloud.stream.kafka.binder.producer-properties.allow.auto.create.topics 但这样的属性不存在,生产者正在自动创建缺少的主题
    • 我在ProducerConfig 中没有看到类似的属性,但我没有看到您观察到的行为,我得到一堆[Producer clientId=producer-1] Error while fetching metadata with correlation id xx : {source-out-0=UNKNOWN_TOPIC_OR_PARTITION},然后是TimeoutException 60 秒后。
    • 我可以看到错误[Producer clientId=producer-1] Error while fetching metadata with correlation id 1 : {Spring-Cloud-Producer=LEADER_NOT_AVAILABLE} 但是,它仍然会创建缺少的主题。我正在使用的属性是-spring.cloud.stream.source=producer-stream-sourcespring.cloud.stream.bindings.producer-stream-source-out-0.destination=Spring-Cloud-Producer
    • 抱歉 - 你是对的,我的经纪人已禁用自动创建 auto.create.topics.enable=false。如果经纪人允许,我会看到它被创建;奇怪的是,生产者没有类似的财产。也许可以在他们的邮件列表之一上联系卡夫卡人?
    • 谷歌kafka mailing list。或者,打开 JIRA 问题 issues.apache.org/jira/projects/KAFKA
    猜你喜欢
    • 2019-07-18
    • 1970-01-01
    • 2019-08-12
    • 1970-01-01
    • 1970-01-01
    • 2021-01-21
    • 2022-10-05
    • 2015-01-24
    • 2015-01-22
    相关资源
    最近更新 更多