1

I am new to Spring Config Server/Client technologies. I am using a spring config server to hold some config values. Config clients will connect to the server and get the values.

If i change some of the config values at the config server, then currently I have to refresh the clients to load the config details from config server again by invoking "/refresh" on each client.

Is there anyway the clients will be notified by the config server and they will then reload the configuration again ?

Rahul Vedpathak
  • 1,346
  • 3
  • 16
  • 30

1 Answers1

1

Yes there is a way.

The solution is to use the Spring Cloud Bus. Using this module, you would link multiple clients to the server using a message broker. The only message broker implementation currently supported by this module is AMQP. Once the clients are connected to the server, invoking the endpoint on the server /bus/refresh will automatically broadcast the configuration changes to all the subscribed clients. This therefore means it is possible to reload configuration changes for any number of clients with one single refresh request which originates at the server.

Tatenda Zifudzi
  • 599
  • 7
  • 22
  • But still it needs to be explicitly invoked - "/bus/refresh". Is there anyway if config server will automatically detect that git repository is changed and will invoke refresh on connected clients? – Rahul Vedpathak Jan 29 '19 at 12:18
  • 2
    There is no other way. You need to use Spring Cloud Bus. – Cristiano Bombazar Jan 29 '19 at 12:50
  • 1
    @RahulVedpathak If you really need that functionality, you could poll the repository every few seconds for changes, and in the event of a change being detected, you would invoke the specified endpoint. This is an ugly solution so be aware of the drawbacks of this e.g. using up bandwidth – Tatenda Zifudzi Jan 29 '19 at 13:20
  • 1
    spring-cloud-config-monitor allows for webhooks to automatically send refresh messages over the bus – spencergibb Jan 31 '19 at 16:45