Skip to content

Kafka Binder does not work with multiple bindings #3173

@sadanyoyo

Description

@sadanyoyo

I use this version of the package: org.springframework.cloud:spring-cloud-stream-binder-kafka:4.3.1, when using the Kafka Binder to consume messages from two different Kafka Cluster the app start fails.

I have a similar application.yml file like the following:

spring:
  application:
    name: xxx
  cloud:
    stream:
      default-binder: outbox
      binders:
        outbox:
          type: kafka
          environment:
            spring:
              kafka:
                bootstrap-servers: broker-0:9092,broker-1:9092,broker-2:9092
                consumer:
                  ack.mode: MANUAL
                  allow.auto.create.topics: false
        eventbus:
          type: kafka
          environment:
            spring:
              kafka:
                bootstrap-servers:eventbus-broker-0:9092,eventbus-broker-1:9092,eventbus-broker-2:9092
        default:
          consumer:
            ack-mode: MANUAL

Localhost is used every time when the connection is established, and the bootstrap-servers configuration does not seem to take effect. It seems that the KafkaBinderConfigurationProperties.mergedProducerConfiguration method overwrites the ProducerConfig.BOOTSTRAP_SERVERS_CONFIG configuration with the kafkaConnectionDetails configuration every time. Since I did not define spring.kafka properties, the default value localhost was used during the KafkaProperties class initialization.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions