Igor Petrov
Igor Petrov

Reputation: 176

How to read Consul key value from client?

Is it possible to re-read custom key/values from consul k/v store with spring-cloud-consul lib? Haven't found an answer in documentation.

Of course it can be accessed with http GET request, but the point is to change some key's value and to make spring application to handle this change immediately.

UPD: unfortunately we've migrated from Consul to config-server, but I guess @RefreshScope should do the magic.

Upvotes: 0

Views: 3257

Answers (1)

spencergibb
spencergibb

Reputation: 25157

spring-cloud-consul auto configures a ConsulClient into the application context. This if from the Ecwid/consul-api client. Usage is the same, but instead of calling new ConsulClient() you would inject one (ie @Autowired ConsulClient consulClient).

Upvotes: 1

Related Questions