繁体   English   中英

骆驼卡夫卡生产者异常登录模块控制标志在 JAAS 配置中不可用

[英]camel kafka producer exception Login module control flag is not available in the JAAS config

我正在通过骆驼从 mqtt 消费并尝试发布到融合的 kafka,但是当我生产到 kafka 时,我收到以下错误

java.lang.IllegalArgumentException: Login module control flag is not available in the JAAS config
    at org.apache.kafka.common.security.JaasConfig.loginModuleControlFlag(JaasConfig.java:85) ~[kafka-clients-3.1.1.jar:na]
    at org.apache.kafka.common.security.JaasConfig.parseAppConfigurationEntry(JaasConfig.java:111) ~[kafka-clients-3.1.1.jar:na]

我用于构建路由 uri 的骆驼配置如下所示

       builder.setScheme("kafka");
       builder.setHost(topicName);
       builder.setParameter("brokers",broker);
       builder.setParameter("saslMechanism","PLAIN");
       builder.setParameter("securityProtocol","SASL_SSL");
       builder.setParameter("saslJaasConfig", "org.apache.kafka.common.security.plain.PlainLoginModule required username=\"username\" password=\"Password\";");

我点击了这个链接Camel-Kafka security protocol SASL_SASL not working试图将 JAAS 配置放在 RAW 中,但它不起作用,即使我试图将 jaas 属性外部化,如此处提到的Kafka“登录模块未在 JAAS 配置中指定”但我仍然我收到同样的错误,不确定 jaas 配置中缺少什么,或者它是 camel kafka 依赖性问题

我正在使用以下依赖关系图骆驼版本 2.25.4

<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-core</artifactId>
            <version>${camel.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-mqtt</artifactId>
            <version>${camel.version}</version>
        </dependency>


        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-spring-boot</artifactId>
            <version>${camel.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-kafka</artifactId>
            <version>${camel.version}</version>
        </dependency>

    </dependencies>

我一直在想办法,有什么帮助吗?

经过一些调试后,我发现当我在 camel 上下文中设置 KafkaComponent 时它可以工作,我在 app.properties 中设置属性然后我使用 KafkaComponent 并将其设置在 camel 上下文中它能够获取属性,但奇怪的是在构建 uri 时我使用了在我的例子中,它没有工作的相同属性看起来像骆驼无法从字符串 uri 中读取属性

        KafkaComponent kafka = new KafkaComponent();
        KafkaConfiguration kafkaConfiguration = new KafkaConfiguration();
        kafkaConfiguration.setBrokers(kafkaBrokerUrl);
        kafkaConfiguration.setSaslMechanism(saslmechanism);
        kafkaConfiguration.setSecurityProtocol(saslprotocol);
        kafkaConfiguration.setSaslJaasConfig(kafkajaasconfig);

        kafka.setConfiguration(kafkaConfiguration);

        getContext().addComponent("kafka", kafka);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM