spring-cloud-aws
spring-cloud-aws copied to clipboard
Parameter Store: Support for periodic polling / refresh
I have recently added Parameter Store support via this library in addition to the existing Consul support to our application of ours. The latter periodically polls Consul for values and applies them to the application context - this makes it incredibly useful when we need to adjust logging levels, for instance.
We do not see such behaviour with the Parameter Store support in this library. Would it be possible to port across the functionality? The same may be relevant to Secrets Manager support, although there may be ramifications for connections such as JDBC.
I currently have tested this
@RefreshScope
@RestController
public class HelloRestController {
@Value("${hello.message}")
private String hello;
@GetMapping("/hello/{name}")
public String hello(@PathVariable String name) {
return this.hello + " " + name;
}
}
- Create
aws ssm put-parameter --name "/config/application/hello.message" --type String --value "Hello" - Start application
- See
Hello - Update
aws ssm put-parameter --name "/config/application/hello.message" --value "Hola" --overwrite - Perform
curl -X POST http://localhost:8080/actuator/refresh - See "Hola"
Make sure you have spring-boot-starter-actuator dependency and the following property management.endpoints.web.exposure.include=refresh.
I currently have tested this
@RefreshScope @RestController public class HelloRestController { @Value("${hello.message}") private String hello; @GetMapping("/hello/{name}") public String hello(@PathVariable String name) { return this.hello + " " + name; } }
- Create
aws ssm put-parameter --name "/config/application/hello.message" --type String --value "Hello"- Start application
- See
Hello- Update
aws ssm put-parameter --name "/config/application/hello.message" --value "Hola" --overwrite- Perform
curl -X POST http://localhost:8080/actuator/refresh- See "Hola"
Make sure you have
spring-boot-starter-actuatordependency and the following propertymanagement.endpoints.web.exposure.include=refresh.
Any recommended approach when running multiple replicas of the service behind a load balancer?
Thanks and best regards.
hi I have the same question, what we should do when we run hundreds of replicas of our microservice?
If eventual consistency is appropriate for the system, then properties pooling can be implemented through a scheduled context refresh.
@AllArgsConstructor
@Configuration
@EnableScheduling
public class ContextRefreshConfig {
private final ContextRefresher contextRefresher;
@Scheduled(initialDelay = {value}, fixedRate = {value})
void refreshProperties() {
contextRefresher.refresh();
}
}