1

I have configured my application with config server and github supported external config files. It works fine when I am having single instance of my application in cloud foundry.

But for multiple instance it is said to implement spring cloud bus to apply external config changes to all the instances. For this I have bind my config server with rabbit MQ instance available on Pivotal Cloud foundry. have added spring.cloud.starter.bus.amqp jar in my build.gradle file.

Problem: But when I am hitting POST request to client app at: http://server:port/bus/refresh the call goes to controller rather than refreshing all the instances and failing as no mapping for same.

Please let me know if I am missing any configuration to make spring-cloud-bus work. Thanks in advance!

application.properties(Client application):

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(Client application):

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= ********

application.properties file in GIT repo:

logging.level.ROOT=WARN
  • 1
    Thank You! Issue got resolved! After changing spring-cloud-bus-starter-amqp jar version from 1.0.1 to 1.1.0 it works out of the box. – Vivek Baranwal Jun 07 '17 at 09:58

1 Answers1

0

What are server.servlet-path and management.context-path in client app set to?

I think you might need to send the request to http://host/<management.context-path>/bus/refresh.

Or better yet, to http://config-server-host/monitor so that it publishes a message to a topic in RabbitMQ and all client apps get notified.

Configuration snippets, source code and more details could be found at my blog post: Refreshable Configuration using Spring Cloud Config Server, Spring Cloud Bus, RabbitMQ and Git

ootero
  • 3,235
  • 2
  • 16
  • 22
  • Thanks ootero for looiking into my issue.I ahve not configured – Vivek Baranwal May 31 '17 at 06:52
  • I have not configure anything for server.servlet-path and management.context-path in my application.yml though the /refresh URL is workiing fine for single instance of my application. To refresh multiple instance below jars added in gradle file spring-cloud-starter-bus-amqp spring-cloud-starter-config Updated application.yml : spring.cloud.bus.refresh.enabled: true spring.cloud.bus.env.enabled: true rabbitmq: host: 10.17.128.102 port: 61613 virtual-host: 02be2c26-4f91-438f-b05a-050333783e88 – Vivek Baranwal May 31 '17 at 07:10
  • I am using config-server provided by PCF itself which is binded with my client application in PCF ahve binded Rabbit MQ instance available on PCF but when I am hitting /monitor on config-server's URI it is giving below error. { "error": "unauthorized", "error_description": "Full authentication is required to access this resource" } – Vivek Baranwal May 31 '17 at 07:12
  • I guess you would need to go through PCF documentation, it might require credentials to access ```/monitor``` – ootero May 31 '17 at 14:06
  • Any guess why bus/refresh is not working are we missing any configuration from client side? we are getting POST https://server:port/bus/refresh does not exist – Vivek Baranwal Jun 01 '17 at 04:21
  • Could you update your post with ```bootstrap``` and ```application``` config properties? Did you try sending the request to ```http://client-app-host/refresh``` ? And again, this will only re-create the beans for that instance of the app, not for every instance. – ootero Jun 01 '17 at 14:18
  • I have updated my post with bootstrap and application config properties file. I have tried with http://client-app-host/refresh and it is working fine and refreshes the bean for single instance. But the problem is I want to refresh multiple instance of my application for which I have added 'spring-cloud-starter-bus-amqp' jar in client side but here http://client-app-host/bus/refresh is not working. Is there any other way to enable this endpoint or anything I am missing in configuration file? – Vivek Baranwal Jun 02 '17 at 06:42
  • Did you read blog post I included in my answer? http://tech.asimio.net/2017/02/02/Refreshable-Configuration-using-Spring-Cloud-Config-Server-Spring-Cloud-Bus-RabbitMQ-and-Git.html#config-server-application-yml My answer also suggest to send a POST request to http://config-server-host/monitor so that all subscribed client apps get notified. Blog post also include a sample payload of to simulate what Bitbucket would send via a webhook – ootero Jun 02 '17 at 14:26
  • Is it means that POST http://config-server-host/monitor to the config server will push the changes to the rabbit MQ subscribed by client application and all instances of client application will gets refreshed with new config changes.POST to http://client-app-host/bus/refresh is not required in this case? If so then what is the difference between POST to http://config-server-host/monitor and POST to http://client-app-host/bus/refresh? – Vivek Baranwal Jun 04 '17 at 10:07
  • In my case on POST http://config-server-host/monitor I can see rabbit MQ will get queues added but client application cannot pick those changes. In rabbit MQ queues formed are seems to be exclusive queue and getting error as "RESOURCE_LOCKED - cannot obtain exclusive access to locked queue" when we try to see messages in the queue – Vivek Baranwal Jun 04 '17 at 10:16