背景
- kafka客戶端是公司內(nèi)部基于spring-kafka封裝的
- spring-boot版本:3.x
- spring-kafka版本:2.1.11.RELEASE
- 集群認證方式:SASL_PLAINTEXT/SCRAM-SHA-512
- 經(jīng)過多年的經(jīng)驗,以及實際驗證,配置是沒問題的,但是業(yè)務(wù)方反饋用相同的配置,還是報錯!
錯誤日志
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已經(jīng)換了,需要把配置項改為低版本的。
IDEA有提示,如果發(fā)現(xiàn)配置項不能解析或不識別,說明該配置項不正確。
具體從哪個版本開始改的,看了一遍github上的版本迭代記錄,并沒有提及,只能是遇到的時候多注意,有問題進行切換即可。文章來源:http://www.zghlxwxcb.cn/news/detail-798840.html
- 低版本使用:spring.kafka.properties.security.protocol=SASL_PLAINTEXT
- 高版本使用:spring.kafka.security.protocol=SASL_PLAINTEXT
問題不好排查,尤其是公司自己封裝的客戶端,配置項和springboot-kafka不太一樣,IDEA也沒有提示,可以作為一個經(jīng)驗吧,當(dāng)配置都確認無誤時,還是報錯或配置不生效,嘗試從因版本變更導(dǎo)致配置項key不同方向入手,別的軟件也有類似的情況。文章來源地址http://www.zghlxwxcb.cn/news/detail-798840.html
到了這里,關(guān)于【Kafka】Kafka客戶端認證失?。篊luster authorization failed.的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!