Cherry
Cherry

Reputation: 33598

How RefreshRemoteApplicationEvent is handled?

The documentation says that when spring cloud config server detects configuration chages it fires an RefreshRemoteApplicationEvent. But documentation said nothing about how that event is handled. So is it true that each application which receive such event shoud handle it by itself? E.g it is not required to refresh entire Spring context when such event was received?

Upvotes: 2

Views: 1699

Answers (1)

C-Otto
C-Otto

Reputation: 5843

I think the documentation only talks about the server side, i.e. the Spring application that talks to the git repository and exposes the condensed information to interested clients. In this process, for example using webhooks, the server can be informed about changes in the git repository, and in turn sends out events to applications that might need to be re-configured.

Your question seems to be concerned about the client side. If your application uses Spring Cloud Config, it should automatically request the new configuration data as soon as the event described above arrives at the client. This in turn should mean that the new configuration values are available or some configured behaviour (log level?) changes.

To actually make the server fire an event that arrives at the client, the documentation suggests Spring Cloud Bus. If you create (for example) a RabbitMQ instance, and make this available to both your clients and your server, Spring automatically attaches to this system and is able to process messages. Additionally, the Spring Cloud Config server automatically sends the desired events using this system, and the clients automatically process these.

In short, if you add Spring Cloud Bus to all involved applications (and make the system used by it, e.g. RabbitMQ, available to them), everything works as expected.

Upvotes: 2

Related Questions