To be able to update configurations without downtime is a must have these days. The @RefreshScope is a mean to achieve that. However it is not free of difficulties. One needs to get in place some form of notifications from the backend to the server and then from the server to the applications. And then, in the application, depending on the bean it sometimes is delicate to acutally recreate the bean at runtime. This requires a more judicious analysis to identify possible runtime issues.

I would appreciate if the application could be able to actually request the most up-to-date value of a configuration. The idea would be:

  • instead of reading the config only at bean creation with @Value, the application code would call Environment.getProperty() whenever the config was needed.

  • under the hood, the PropertySourceimplementation would actually hit the config-server. Of course, this would not be the default behaviour. The default behaviour would be as it is today (without reaching the server), but, provided a special config was done in bootstrap.yml, the PropertySourcewould hit the server.

  • in the server side, maybe a new parameter in the request would be used to indicate to the server that it should reach the backend again.

In practice, in the application code I would not actually call Environment.getProperty() every time the config was needed. I would wrap this call with some cache with a little TTL (say, 30 seconds).

During application startup, with this approach it would be costly to actually reach the server for each resolution of all the @Values of the application. Therefore a possible optimization would be that, during application startup, calls to PropertySource.getProperty() would not hit the server. The spring-cloud client infrastructure would be able to know when the startup is done by registering application listeners in the SpringApplication.

If there is already a mean to achieve something similar to this please let me know.

Comment From: spencergibb

If all you are doing is updating configuration @RefreshScope isn't needed if you are using @ConfigurationProperties.

Comment From: spring-projects-issues

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

Comment From: jgslima

You can go ahead an close it. Thank you.