第一坑:
spring:
application:
name: stream-rabbitmq
cloud:
stream:
binders:
defaultRabbit:
type: rabbit
environment:
spring:
rabbitmq:
host: 8.8.8.8
port: 5672
username: admin
password: admin
virtual-host: /
bindings:
input:
destination: test123
content-type: text/plain
binder: defaultRabbit
根據資料,這樣配置就可以使用,當我配置完之后啟動,出現了第一個問題,根據我配置的host訪問之后,會自動訪問localhost的rabbitmq,從而導致報localhost訪問失敗。具體什么原因還沒有找到,我解決的方法
spring:
application:
name: stream-rabbitmq-consumer
cloud:
stream:
bindings:
input:
destination: test123
content-type: text/plain
rabbitmq:
host: 8.8.8.8
port: 5672
username: admin
password: admin
將rabbitmq配置單獨放出來
第二坑
出現nested exception is java.lang.IllegalStateException: Failed to convert message: '' to outbound message.錯誤,發送訊息一直是訊息轉換錯誤,試了很久才發現原來是配置 content-type: text/plain 的問題,一定要注意自己填寫的什么型別,如果型別不對,就會出現這個錯誤
第三坑
組態檔中bindings 里面配置的屬性無效,不管怎么修改,都沒有生效,因為能夠訪問,就是這些配置沒有用,導致分組也沒有效果。后來發現問題原來是在@EnableBinding(Barista.class) 注入類的時候,注入的是我自己定義的Barista類,加載的是Barista類中的資訊,跟組態檔沒有關系,那應該是注解的方式。如果要組態檔生效,將注入的類改成Source類
uj5u.com熱心網友回復:
邊填坑邊提高轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/20926.html
標籤:Web 開發
