【问题标题】:Customize input kafka topic name for Spring Cloud Stream为 Spring Cloud Stream 自定义输入 kafka 主题名称
【发布时间】:2021-10-13 07:59:08
【问题描述】:

由于不推荐使用 @EnableBinding 和 @StreamListener(Sink.INPUT) 以支持函数,因此我需要创建一个可以从 Kafka 主题读取消息的使用者。 我的消费者函数:

    @Bean
    public Consumer<Person> log() {
        return person -> {
            System.out.println("Received: " + person);
        };
    }

,application.yml 配置

spring:
  cloud:
    stream:
      kafka:
        binder:
          brokers: localhost:9092
      bindings:
        consumer:
          destination: messages
          contentType: application/json

它没有连接到主题 messages,而是一直连接到 log-in-0 主题。 我该如何解决这个问题?

【问题讨论】:

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


    【解决方案1】:
    spring.cloud.stream.bindings.log-in-0.destination=messages
    

    【讨论】:

      猜你喜欢
      • 2018-07-18
      • 2020-12-22
      • 1970-01-01
      • 2019-09-07
      • 2022-12-19
      • 2019-04-17
      • 2017-11-20
      • 1970-01-01
      • 2020-03-08
      相关资源
      最近更新 更多