我已经使用配置服务器和github支持的外部配置文件配置了我的应用程序。当我在cloud foundry中拥有我的应用程序的单个实例时,它工作得很好。
但是对于多个实例,据说实现了spring cloud bus来将外部配置更改应用到所有实例。为此,我将我的配置服务器与Pivotal Cloud foundry上提供的rabbit实例绑定在一起。在我的build.gradle文件中添加了spring.cloud.starter.bus.amqp jar。
问题:但是当我在http://server:port/bus/refresh向客户端应用程序发送POST请求时,调用会转到控制器,而不是刷新所有实例,并且由于没有映射而失败。
如果我缺少任何配置来使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 repo中的application.properties文件:
logging.level.ROOT=WARN发布于 2017-05-30 22:42:06
客户端应用程序中的server.servlet-path和management.context-path设置为什么?
我认为您可能需要将请求发送到http://host/<management.context-path>/bus/refresh。
或者更好的是,发送到http://config-server-host/monitor,这样它就可以向RabbitMQ中的主题发布消息,并且所有客户端应用程序都会收到通知。
配置片段、源代码和更多细节可以在我的博客帖子中找到:Refreshable Configuration using Spring Cloud Config Server, Spring Cloud Bus, RabbitMQ and Git
https://stackoverflow.com/questions/44219786
复制相似问题