1

I'd like to expose the current value of the configuration property of a spring-bean using spring-actuator https://docs.spring.io/spring-boot/docs/current/actuator-api/htmlsingle/#env

GET /actuator/env/{props}

I have 2 services:

  • Cloud config service
  • Application service

The cloud config have 2 configurations are maximum-upload-allow = 1M and file-type = png

Application service load those configs from the cloud-config service

like:

@Configuration @Getter
public class ApplicationConfigurationProperty {
  @Value("${maximum-upload-allow}")
  private String maximumImageSize;
}

@Configuration  @RefreshScope  @Getter
public class FileConfigurationProperty {
  @Value("${file-type}")
  private String fileType;
}
  • I can get my configuration as well via GET /actuator/env/maximum-upload-allow (1M) and GET /actuator/env/file-type (png)

Now when I update configuration value maximum-upload-allow = 2M and file-type = jpg

Then I do refresh-scope by call bus-refresh https://cloud.spring.io/spring-cloud-static/spring-cloud-bus/2.1.4.RELEASE/multi/multi__bus_endpoints.html

I'd like to see my configurations using spring-actuator are:

GET /actuator/env/maximum-upload-allow => 1M (because No refreshscope)

GET /actuator/env/file-type => jpg (I marked as refreshscope)

but actually, spring-actuator return both new values (2M and jpg)

Q: How I can get my runtime value of maximum-upload-allow is 1M (current value because of NO RefreshScope here?

--- Update

@Configuration @Setter @Getter @ConfigurationProperties
public class ApplicationConfigurationProperty {
  @Value("${maximum-upload-allow}")
  private String maximumImageSize;
}

This configuration value refreshed without @RefreshScope annotation

I think these is correct behaviours mention here https://cloud.spring.io/spring-cloud-static/spring-cloud-bus/2.1.4.RELEASE/multi/multi__bus_endpoints.html

Thank you in advance.

2
  • Have you tried delaying the cache refresh scope to higher interval management.endpoint.beans.cache.time-to-live=60s If not then some more pointers can be located here gist.github.com/dsyer/a43fe5f74427b371519af68c5c4904c7 Commented Mar 3, 2021 at 11:44
  • I would like to get my old value (maximum-upload-allow=1M) until I restart my application service. I don't want this config is refreshable Commented Mar 3, 2021 at 12:03

1 Answer 1

0

I found a simple solution is to implement a new actuator endpoint which is load @RefreshScope and use Reflection to read bean's properties

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.