Spring Cloud Configuration - auto-enable Refresh Endpoint & Git monitoring

el n00b picture el n00b · Sep 5, 2016 · Viewed 13.1k times · Source

Questions

I am starting to learn Spring Cloud starting with Spring Config. There are two basic questions as I have to get me onto the next step in my learning process (moving on to Service Discovery via Consul).

  1. How do I auto-enable the /refresh endpoint to POST to?
  2. Is there a way to automatically monitor for updates in Git?

For #1 I implemented my own @RestController/@RequestMapping but none of the tutorials I was following mentioned that. I checked my Maven configuration and it matches what the samples were providing but it's not popping up.

I found a post for the second question here: spring cloud auto refresh config server property. I was just wondering if there were any updates since November 2015 on this.

Both of these things seem to be exceedingly handy and will be directly intertwined with my Consul learning as I can push configuration updates automatically to everyone that is registered as a service. Once I get there I can work on the restarts too, but that is later.

Updates

I got an answer to #1. I had botched my dependencies configuration in my Maven module. After triple-checking the configuration it turns out it was just pilot error. Still working on #2, though - if anyone has any updates it would be appreciated.

Answer

Liping Huang picture Liping Huang · Sep 6, 2016

For #1, Spring cloud config intrdouced the @RefreshScope annotation which will expose the /refresh endpoint (over HTTP or JMX)

For #2, after '/refresh', spring cloud config will take the latest git commit, For the config changes, essentially there are two ways, 1) pull the changes 2) push the changes, spring cloud bus approach is based on the rabbitmq to push the config chagnes.

Reference

Refresh Scope