我已经用配置服务器和github支持的外部配置文件配置了我的应用程序。当我在云铸造厂中拥有应用程序的单个实例时,它工作正常。
但是对于多个实例,据说它实现了 spring 云总线以将外部配置更改应用于所有实例。为此,我将我的配置服务器与 Pivotal Cloud foundry 上可用的兔子 MQ 实例绑定在一起。在我的build.gradle文件中添加了spring.cloud.starter.bus.amqp jar。
问题:但是当我在以下位置对客户端应用程序发出 POST 请求时:http://server:port/bus/refresh 调用将转到控制器,而不是刷新所有实例并失败,因为没有映射。
如果我缺少任何使 spring-cloud-bus 工作的配置,请告诉我。提前感谢!
application.properties(客户端应用程序(:
spring.profiles=cloud
spring.rabbitmq.host= 10.17.128.102
spring.rabbitmq.port= 5672
spring.rabbitmq.virtual-host= *****
spring.rabbitmq.username= ******
spring.rabbitmq.password= *****
rabbit.exchangeName= demoPartyServiceexc
rabbit.routingKey= demoPartyService
rabbit.queueName= demoPartyServicequeue
logging.level.ROOT= ERROR
bootstrap.properties(客户端应用程序(:
spring.application.name=demo-api
spring.cloud.bus.enabled=true
spring.cloud.config.bus.enabled=true
spring.cloud.bus.amqp.enabled=true
spring.cloud.bus.refresh.enabled=true
spring.cloud.bus.env.enabled=true
spring.cloud.config.uri=https://config-a5e99419-8179-47f7-8c23-62ed5b38db0b.cf.com
spring.cloud.config.server.bootstrap=true
spring.cloud.config.server.git.uri= My Github repository URI
spring.cloud.config.server.git.username= ********
spring.cloud.config.server.git.password= ********
GIT 存储库中的应用程序属性文件:
logging.level.ROOT=WARN
应用中的server.servlet-path
和management.context-path
设置为什么?
我认为您可能需要将请求发送给http://host/<management.context-path>/bus/refresh
.
或者更好的是,http://config-server-host/monitor
以便它向RabbitMQ
中的主题发布消息,并且所有客户端应用程序都会收到通知。
配置片段,源代码和更多详细信息可以在我的博客文章中找到:使用Spring Cloud Config Server,Spring Cloud Bus,RabbitMQ和Git的可刷新配置