spring cloud 多重绑定在 3.2.2 jar 中不起作用

发布于 2025-01-10 09:31:56 字数 2643 浏览 0 评论 0原文

我正在尝试使用 Avro 输入消息将 json(topic-json) 和 avro(topic-avro) 消息发送到多个主题。当我将“binder”设置为值(即binder:kafka-1-with-ssl)时,出现 application.yaml 错误。我还使用下面的 jars:

"org.springframework.cloud:spring-cloud-stream-binder-kafka-streams",-->3.2.2
"org.springframework.cloud:spring-cloud-stream-binder-kafka",-->3.2.2

dependencyManagement {
    imports {
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:2021.0.1"
    }
}

我不确定我在下面的 yaml 文件中做错了什么。

spring:
  cloud:
    stream:
      function:
        definition: processor
      bindings:
        processor-in-0:
          content-type: application/json
          destination: input-topic-in-avro
          consumer:
            use-native-decoding: true
        processor-out-0:
          binder: kafka-1-with-ssl
          destination: topic-json
          content-type: application/json
          producer:
            use-native-encoding: true
            key-serializer: org.apache.kafka.common.serialization.Serdes$StringSerde
            value-serializer: org.springframework.kafka.support.serializer.JsonSerde
        error-out-0:
          binder: kafka-2-with-ssl
          destination: topic-avro
          content-type: application/json
          producer:
            use-native-encoding: true
            key-serializer: org.apache.kafka.common.serialization.StringSerializer
            value-serializer: io.confluent.kafka.serializers.KafkaAvroSerializer
      binders:
        kafka-1-with-ssl:
          type: kafka
          environment:
            spring.cloud.stream.kafka.binder:
              auto-create-topics: false
              brokers: <broker-name>
              configuration: # Common properties for SSL...
              producer-properties:
                key.serializer: org.apache.kafka.common.serialization.StringSerializer
                value.serializer: org.springframework.kafka.support.serializer.JsonSerializer
        kafka-2-with-ssl:
          type: kafka
          environment:
            spring:
              cloud:
                stream:
                  kafka:
                    binder:
                      auto-create-topics: false
                      brokers: <broker-name>
                      configuration: # Common properties for SSL...
                      producer-properties:
                        key.serializer: org.apache.kafka.common.serialization.StringSerializer
                        value.serializer: io.confluent.kafka.serializers.KafkaAvroSerializer
                        schema.registry.url: <registry-url>

先感谢您。

I am trying to send json(topic-json) and avro(topic-avro) messages to multiple topics with Avro input message. I am getting application.yaml error when I set "binder" with value i.e. binder: kafka-1-with-ssl. I am also using below jars:

"org.springframework.cloud:spring-cloud-stream-binder-kafka-streams",-->3.2.2
"org.springframework.cloud:spring-cloud-stream-binder-kafka",-->3.2.2

dependencyManagement {
    imports {
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:2021.0.1"
    }
}

I am not sure what I am doing wrong in below yaml file.

spring:
  cloud:
    stream:
      function:
        definition: processor
      bindings:
        processor-in-0:
          content-type: application/json
          destination: input-topic-in-avro
          consumer:
            use-native-decoding: true
        processor-out-0:
          binder: kafka-1-with-ssl
          destination: topic-json
          content-type: application/json
          producer:
            use-native-encoding: true
            key-serializer: org.apache.kafka.common.serialization.Serdes$StringSerde
            value-serializer: org.springframework.kafka.support.serializer.JsonSerde
        error-out-0:
          binder: kafka-2-with-ssl
          destination: topic-avro
          content-type: application/json
          producer:
            use-native-encoding: true
            key-serializer: org.apache.kafka.common.serialization.StringSerializer
            value-serializer: io.confluent.kafka.serializers.KafkaAvroSerializer
      binders:
        kafka-1-with-ssl:
          type: kafka
          environment:
            spring.cloud.stream.kafka.binder:
              auto-create-topics: false
              brokers: <broker-name>
              configuration: # Common properties for SSL...
              producer-properties:
                key.serializer: org.apache.kafka.common.serialization.StringSerializer
                value.serializer: org.springframework.kafka.support.serializer.JsonSerializer
        kafka-2-with-ssl:
          type: kafka
          environment:
            spring:
              cloud:
                stream:
                  kafka:
                    binder:
                      auto-create-topics: false
                      brokers: <broker-name>
                      configuration: # Common properties for SSL...
                      producer-properties:
                        key.serializer: org.apache.kafka.common.serialization.StringSerializer
                        value.serializer: io.confluent.kafka.serializers.KafkaAvroSerializer
                        schema.registry.url: <registry-url>

Thank you in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文