springcloud-bus消息总线

1.configserver引入bus依赖

        <!--引入bus依赖-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-bus-amqp</artifactId>
        </dependency>

 2.configserver配置文件

server.port=9999
spring.application.name=configserver

spring.cloud.consul.host=localhost
spring.cloud.consul.port=8500
spring.cloud.consul.discovery.service-name=${spring.application.name}

spring.cloud.config.server.svn.uri=https://DESKTOP-VQE7HEH/svn/ems/
spring.cloud.config.server.svn.username=taohj
spring.cloud.config.server.svn.password=taohj
spring.cloud.config.server.default-label=
spring.profiles.active=subversion
management.endpoints.web.exposure.include=*

spring.rabbitmq.host=127.0.0.1
spring.rabbitmq.port=5672
spring.rabbitmq.username=admin
spring.rabbitmq.password=admin

 3.configclient引入bus依赖

        <!--引入bus依赖-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-bus-amqp</artifactId>
        </dependency>

 4.configclient配置文件

application.properties

server.port=9991
spring.application.name=configclient

spring.cloud.consul.host=localhost
spring.cloud.consul.port=8500
spring.cloud.consul.discovery.service-name=${spring.application.name}

management.endpoints.web.exposure.include=*
spring.cloud.config.fail-fast=true

spring.rabbitmq.host=127.0.0.1
spring.rabbitmq.port=5672
spring.rabbitmq.username=admin
spring.rabbitmq.password=admin


name=${name}

 5.刷新

SVN配置文件修改提交后,configserver需要post发送刷新请求 URL:http://127.0.0.1:9999/actuator/bus-refresh,再次访问configclient controller配置文件修改后的值才能被重新加载。
http://127.0.0.1:9999/actuator/bus-refresh 刷新所有微服务
http://127.0.0.1:9999/actuator/bus-refresh/configclient:9090 刷新某个端口的微服务
http://127.0.0.1:9999/actuator/bus-refresh/configclient          刷新某个微服务

posted @ 2020-08-20 11:06  陶海军  阅读(162)  评论(0编辑  收藏  举报