bus rabbitmq binder-rabbit
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-bus</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
</dependency>
actuator
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
暴露bus-refresh刷新路径
rabbitmq连接配置
spring:
application:
name: config-server
cloud:
config:
server:
git:
uri: https://gitee.com/pigeon01/springcloud1
search-paths: config
rabbitmq:
host: 192.168.64.140
port: 5672
username: admin
password: admin
virtual-host: /
server:
port: 6001
eureka:
client:
service-url:
defaultZone: http://eureka1:2001/eureka,http://eureka2:2002/eureka
management:
endpoints:
web:
exposure:
include: bus-refresh
spring:
application:
name: item-service
rabbitmq:
host: 192.168.64.140
port: 5672
username: admin
password: admin
virtual-host: /
#item 8001 user8101 order8201
server:
port: 8001
cloud:
config:
override-none: true #防止从配置中心下载的配置,覆盖本地命令参数
eureka:
client:
service-url:
# 可以从云服务商购买不同地点的 eureka服务器
# 这里可以改成云服务商提供的地点
# 自己的服务器只能用defaultZone
defaultZone: http://eureka1:2001/eureka,http://eureka2:2002/eureka
1.向http://localhost:6001/actuator/bus-refresh提交一个post请求
2.观察2.3.4控制台是否重新连接6001,刷新配置
有选择地可以发送至想发送的模块,使用的是主题交换机
添加99用户
POST http://localhost:6001/actuator/bus-refresh/user-service
GET http://localhost:3002/user-service/99
bootstrap.yml
ignore-interfaces: #忽略的网卡
spring:
cloud:
inetutils:
preferred-networks:
- 172\.18\.10\..+
application.yml
spring:
application:
name: config-server
cloud:
config:
server:
git:
uri: https://gitee.com/pigeon01/springcloud1
search-paths: config
rabbitmq:
host: 192.168.64.140
port: 5672
username: admin
password: admin
virtual-host: /
server:
port: 6001
eureka:
client:
service-url:
defaultZone: http://eureka1:2001/eureka,http://eureka2:2002/eureka
instance:
prefer-ip-address: true
instance-id: ${spring.cloud.client.ip-address}:${spring.application.name}:${server.port}
management:
endpoints:
web:
exposure:
include: bus-refresh
实现效果
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://blog.csdn.net/weixin_55740233/article/details/121470378
内容来源于网络,如有侵权,请联系作者删除!