Search code examples
spring-bootapache-camelspring-cloud-config

Spring Cloud Config fails to update properties dynamically


I have a Camel Spring Boot application where I am printing the value of a property which is set using Spring Cloud Config Server (via Git commit id plugin). The issue is that the value of the property in Camel application is not updated once the value is committed to Git. I have to restart the Camel application which fails the purpose of Spring Cloud Config server. Please note that we are using Git file system in our local machine.

The name of the properties file is CamelSpringBootSample-dev.properties.

As soon as I commit, the config server publishes the updated value at the endpoint on refresh: http://localhost:8888/CamelSpringBootSample/dev

I have also made the Camel application end point available at: http://localhost:8181/actuator/env

Here the value of the property is not updated on refresh. However, if I restart the Camel application, the value is reflecting.

The source code for all the three projects are uploaded in github.com.

  1. The config server: https://github.com/sreejeshraj/config-server

  2. The Camel client project (which uses the config server to configure itself): https://github.com/sreejeshraj/camel-config-server Please do not get misled by the repository name camel-config-server. This is the client of config server, but I accidentally named it incorrectly, apologies.

  3. The local git repository where the configuration properties are stored: https://github.com/sreejeshraj/Git-Config

Please note that I have used the annotation @RefreshScope in my Spring bean component class.

Can you please help me with this? Thanks in advance.


Solution

  • You have to set:

    management.endpoints.web.exposure.include=refresh
    

    in bootstrap.properties or bootstrap.yml.

    and trigger the /actuator/refresh endpoint.

    See @RefreshScope and /refresh not working

    Note that as said in the comments, Camel does not update its values when a Spring beans is refreshed and there is no plan to implement this feature. (https://issues.apache.org/jira/browse/CAMEL-13892). You probably could find a solution through Spring Cloud Bus.