1
votes

We are using spring config client to refresh properties dynamically. We have added spring-cloud-starter-bus-kafka on the classpath and everything works fine. Pom version of all these dependencies is 2.X.

What I want to do is, remove spring-cloud-starter-bus-kafka and add my custom code to pick up consumer event and refresh context and in turn refresh properties using cloud config client. I believe somewhere Spring is calling ConfigServicePropertySourceLocator.locate. Basically, I want to just replicate what Spring has done in spring-cloud-starter-bus-kafka to make refreshing of properties in real time possible.

The reason I'm doing all this is, I'm internally using an older version of kafka-clients. We have a homegrown version of that, it supports encryption and what not. Problem is coming since spring-cloud-starter-bus-kafka is using 2.X version of kakfa-clients and our home version is not ready for that. Due to this, either one of them is working at one point in time.

Can someone show me some pointer on what needs to be done to consume refresh event from kafka and refresh the property? I don't imagine this being too much complicated. It should be consuming kafka event and somewhere calling ConfigSourceLocator to refresh the properties.

1

1 Answers

3
votes

It's even simpler than that. If you look in the RefreshListener class you can see that all it does is

    Set<String> keys = this.contextRefresher.refresh();
    log.info("Received remote refresh request. Keys refreshed " + keys);

Where contextRefresher is a org.springframework.cloud.context.refresh.ContextRefresher.

This will trigger the code that handles looking up configuration automatically.