SpringCloud學習 十三 Bus

2021-10-16 22:10:52 字數 1374 閱讀 8149

建立module cloud-config-client-3366,這個模組和3355一摸一樣

然後在3344 3355和3366的專案模組中的pom.xml中加入訊息匯流排支援

org.springframework.cloud

spring-cloud-starter-bus-amqp

同時在在 3355和3366的專案的yml檔案中加入以下配置

# 暴露監控端點

management:

endpoints:

web:

exposure:

include: "*"

spring:

rabbitmq:

rabbitmq:

host: 192.168.31.205

port: 5672

username: admin

password: 123456

virtual-host: my_vhost

在3344服務端加入以下配置

# 暴露監控端點

management:

endpoints:

web:

exposure:

include: "bus-refresh"

spring:

rabbitmq:

rabbitmq:

host: 192.168.31.205

port: 5672

username: admin

password: 123456

virtual-host: my_vhost

啟動專案後,執行localhost:3366/serverport或者localhost:3355/serverport都可以獲取到對應的配置資訊

然後修改github上配置檔案的資訊,在執行curl -x post "http://localhost:3344/actuator/bus-refresh",3355和3366不需要重啟專案即可更新配置資訊啦

我們可以修改curl命令來實現定製發布,例如curl -x post "http://localhost:3344/actuator/bus-refresh/config-client:3355",config-client:3355代表服務名稱:服務埠,執行了這條命令,3355和github保持一致,3366還是為更新前的配置

SpringCloud相關學習

錯過了這一篇,你可能再也學不會 spring cloud 了!spring boot做為下一代 web 框架,spring cloud 作為最新最火的微服務的翹楚,你還有什麼理由拒絕。趕快上船吧,老船長帶你飛。終章不是最後一篇,它是乙個彙總,未來還會寫很多篇。案例全部採用spring boot 1....

SpringCloud學習筆記

筆記學習位址 筆記內容皆摘抄自以上部落格並親自驗證。在此感謝原博主分享 本文出自方志朋的部落格 環境 ide idea jdk8 a 服務的註冊與發現 1 spring eureka 服務端 實現springcloud的服務註冊與發現功能。1 springboot專案搭建 使用start.sprin...

Spring Cloud學習路線

1 服務治理 eureka,consul,zookeeper 2 配置中心 spring cloud config 客戶端和服務端,配置檔案可以放在git svn 本地 vault等 3 負載均衡 ribbon 客戶端 4 服務閘道器 zuul 5 斷路器 hystrix 容錯保護 6 集群監控 t...