spring java.lang.RuntimeException:从Sping Boot 到Azure事件中心,不可为空的字段authBytes被序列化为空

velaa5lx  于 2022-11-21  发布在  Spring
关注(0)|答案(1)|浏览(119)

bounty将在2天后过期。回答此问题可获得+50的声望奖励。Jeff Cook正在寻找来自知名来源的答案:需要授权工作解决方案。我正在企业Azure云上尝试此解决方案

我正在使用v2.7.5开发一个简单的Sping Boot 应用程序,并尝试向事件中心发送消息。有人能指导我吗?
错误:

java.lang.RuntimeException: non-nullable field authBytes was serialized as null
    at org.apache.kafka.common.message.SaslAuthenticateResponseData.read(SaslAuthenticateResponseData.java:137) ~[kafka-clients-3.1.2.jar:na]
    at org.apache.kafka.common.message.SaslAuthenticateResponseData.<init>(SaslAuthenticateResponseData.java:86) ~[kafka-clients-3.1.2.jar:na]
    at org.apache.kafka.common.requests.SaslAuthenticateResponse.parse(SaslAuthenticateResponse.java:76) ~[kafka-clients-3.1.2.jar:na]
    at org.apache.kafka.common.requests.AbstractResponse.parseResponse(AbstractResponse.java:187) ~[kafka-clients-3.1.2.jar:na]
    at org.apache.kafka.common.requests.AbstractResponse.parseResponse(AbstractResponse.java:109) ~[kafka-clients-3.1.2.jar:na]
    at org.apache.kafka.clients.NetworkClient.parseResponse(NetworkClient.java:729) [kafka-clients-3.1.2.jar:na]
    at org.apache.kafka.common.security.authenticator.SaslClientAuthenticator.receiveKafkaResponse(SaslClientAuthenticator.java:576) ~[kafka-clients-3.1.2.jar:na]
    at org.apache.kafka.common.security.authenticator.SaslClientAuthenticator.receiveToken(SaslClientAuthenticator.java:508) ~[kafka-clients-3.1.2.jar:na]
    at org.apache.kafka.common.security.authenticator.SaslClientAuthenticator.authenticate(SaslClientAuthenticator.java:302) ~[kafka-clients-3.1.2.jar:na]
    at org.apache.kafka.common.network.KafkaChannel.prepare(KafkaChannel.java:181) ~[kafka-clients-3.1.2.jar:na]
    at org.apache.kafka.common.network.Selector.pollSelectionKeys(Selector.java:543) [kafka-clients-3.1.2.jar:na]
    at org.apache.kafka.common.network.Selector.poll(Selector.java:481) [kafka-clients-3.1.2.jar:na]
    at org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:560) [kafka-clients-3.1.2.jar:na]
    at org.apache.kafka.clients.NetworkClientUtils.awaitReady(NetworkClientUtils.java:73) [kafka-clients-3.1.2.jar:na]
    at org.apache.kafka.clients.producer.internals.Sender.awaitNodeReady(Sender.java:526) [kafka-clients-3.1.2.jar:na]
    at org.apache.kafka.clients.producer.internals.Sender.maybeSendAndPollTransactionalRequest(Sender.java:447) [kafka-clients-3.1.2.jar:na]
    at org.apache.kafka.clients.producer.internals.Sender.runOnce(Sender.java:316) [kafka-clients-3.1.2.jar:na]
    at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:243) [kafka-clients-3.1.2.jar:na]
    at java.lang.Thread.run(Thread.java:748) [na:1.8.0_202]

application.properties

server:
  port: 8088
spring:
  kafka:
    client-id: first-producer
    properties:
      sasl.jaas.config: org.apache.kafka.common.security.plain.PlainLoginModule required username="$ConnectionString" password="SOME VALUE";
      sasl.mechanism: PLAIN
      security.protocol: SASL_SSL
    consumer:
      bootstrap-servers: AAA.servicebus.windows.net:9093
      group-id: group-id
      auto-offset-reset: earliest
      enable-auto-commit: true
      key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
      value-deserializer: org.apache.kafka.common.serialization.StringDeserializer
    producer:
      bootstrap-servers: AAA.servicebus.windows.net:9093
      key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
      value-deserializer: org.apache.kafka.common.serialization.StringDeserializer
topic:
  name: t-employee

有什么建议吗?
pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.5</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>kafka-producer-consumer</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>kafka-producer-consumer</name>
    <description>Demo project for Spring Boot</description>
    
    <properties>
        <java.version>1.8</java.version>
    </properties>
    
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.kafka</groupId>
            <artifactId>spring-kafka</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.datatype</groupId>
            <artifactId>jackson-datatype-jsr310</artifactId>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.kafka</groupId>
            <artifactId>spring-kafka-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>
hrysbysz

hrysbysz1#

我能够通过升级定价层:标准来解决它。这解决了这个问题。我还从这里得到了提示:Not able connect to EventHub via KAFKA api

相关问题