'Spring Cloud Bus Getting Refresh Event for Plain Text

I am trying to get our config server to host plain text files more dynamically. I am currently having a Spring config server and a few services using it to get configuration. I am also have kafka up for Spring Cloud Bus connected to both config server and the clients.

Additionally, I am using config server to server some plain text files (as described in https://cloud.spring.io/spring-cloud-static/spring-cloud.html#_serving_plain_text). I am wishing to get the client to refresh, if the plain text files are updated.

When normal properties are updated, my client through spring cloud bus can receive the refresh request, and perform the refresh, however, when the plain text files are updated, the same thing doesn't happen. The config server logs showed that it registered the changes, but there's no refresh event broadcast to the clients through kafka.

I am wondering if there's a way to achieve this automatic refresh for plain text files.

My current thought: Have a refresh event listener to catch the kafka message, and do refresh for necessary bean.

example:

@Configuration
public class FileReloadListener implements ApplicationListener<RefreshRemoteApplicationEvent> {

  @Override
  public void onApplicationEvent(RefreshRemoteApplicationEvent event) {
    // refresh the needed beans
  }
}

Any idea? Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source