2023-12-21 18:00:44.051 [kafka-producer-network-thread | producer-1] INFO o.a.k.c.p.i.TransactionManager - [Producer clientId=producer-1] Transiting to fatal error state due to org.apache.kafka.common.errors.ClusterAuthorizationException: Cluster authorization failed.
2023-12-21 18:00:44.066 [http-nio-8082-exec-1] ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: org.apache.kafka.common.KafkaException: Cannot execute transactional method because we are in an error state] with root cause
org.apache.kafka.common.errors.ClusterAuthorizationException: Cluster authorization failed.
2023-12-21 18:00:44.156 [kafka-producer-network-thread | producer-1] ERROR o.a.k.c.producer.internals.Sender - [Producer clientId=producer-1] Aborting producer batches due to fatal error
org.apache.kafka.common.errors.ClusterAuthorizationException: Cluster authorization failed.
2023-12-21 18:00:44.159 [kafka-producer-network-thread | producer-1] ERROR o.s.k.s.LoggingProducerListener - Exception thrown when sending a message with key='null' and payload='测试消息' to topic test-topic:
org.apache.kafka.common.errors.ClusterAuthorizationException: Cluster authorization failed.
封装的kafka客户端版本过低,高版本的配置项:security.protocol 的key已经换了,需要把配置项改为低版本的。
IDEA有提示,如果发现配置项不能解析或不识别,说明该配置项不正确。
具体从哪个版本开始改的,看了一遍github上的版本迭代记录,并没有提及,只能是遇到的时候多注意,有问题进行切换即可。
问题不好排查,尤其是公司自己封装的客户端,配置项和springboot-kafka不太一样,IDEA也没有提示,可以作为一个经验吧,当配置都确认无误时,还是报错或配置不生效,尝试从因版本变更导致配置项key不同方向入手,别的软件也有类似的情况。