I have implemented shutdown API in my spring-boot project by setting following values in application.properties:
management.endpoint.shutdown.enabled=true
management.endpoint.info.enabled=true
management.endpoints.web.exposure.include=*
Now I want to disable the shutdown API dynamically with help of database like I will have those above configurations as key, value pair that I can change anytime.
On its change, the application should get also updated with the new config values thereby shutdown API gets disabled .
You could use Netflix Archaius
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-archaius</artifactId>
</dependency>
You don't need to use @Value
annotation here.
Usage
DynamicStringProperty dynamicProperty = DynamicPropertyFactory.getInstance().getStringProperty("management.endpoint.shutdown.enabled", "default value here");
String propertyCurrentValue = dynamicProperty.get();
If the data changes in property file at any point, Archaius will detect it at runtime and will start retrieving the new values.
Useful references
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.