Spring Cloud Kafka流的连接错误

时间:2018-10-08 02:49:40

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

我正在尝试在一种托管的kafka提供程序身份验证类型为SASL_SSL上连接kafka流 下面是我的application.yml

spring:
  cloud:
    stream:
      kafka:
        binder:
          brokers: ark-01.srvs.cloudkafka.com:9094,ark-02.srvs.cloudkafka.com:9094,ark-03.srvs.cloudkafka.com:9094
          configuration:
            security:
              protocol: SASL_SSL
          jaas:
            loginmodule : org.apache.kafka.common.security.scram.ScramLoginModule required username="un" password="pwd"
        sasl :
          jaas :
            config : org.apache.kafka.common.security.scram.ScramLoginModule required username="un" password="pwd"

      bindings:
        greetings-in:
          destination: 2wow01xi-default
          contentType: application/json
        greetings-out:
          destination: 2wow01xi-default
          contentType: application/json

我无法连接,请告知。

3 个答案:

答案 0 :(得分:0)

...jaas.loginModule需要大写M

尝试

    binder:
      jaas:
        loginModule : org.apache.kafka.common.security.scram.ScramLoginModule
        options:
          username: un
          password: pwd

答案 1 :(得分:0)

我已使用以下配置@ gary-russell解决了上述问题,请确认其是否正确方法

    spring:
        cloud.stream:
           bindings:
    greetings-in:
      destination: ms-dev-logs
      contentType: application/json
      binder: kafka1
    greetings-out:
      destination: ms-dev-logs
      contentType: application/json
      binder: kafka1
  binders:
    kafka1: 
    type: kafka
    environment:
        spring:
          cloud:
            stream:
              kafka:
                binder.brokers: ipaddr:9092,ipaddr9092,ipaddr:9092
                streams :
                  binder :
                    configuration :
                      default.key.serde: org.apache.kafka.common.serialization.Serdes$StringSerde
                      default.value.serde: org.springframework.kafka.support.serializer.JsonSerde

  kafka.binder:
    configuration:
      security.protocol: SASL_PLAINTEXT
      sasl.mechanism: SCRAM-SHA-256
kafka:
  properties:
    sasl:
      jaas:
        config : org.apache.kafka.common.security.scram.ScramLoginModule required username="usr" password="pws";

答案 2 :(得分:0)

我发现问题出在Spring Cloud Kafka库中,Spring Cloud团队将在下一版本中对其进行修复,有关详细信息,请参见

https://github.com/spring-cloud/spring-cloud-stream-binder-kafka/issues/460