Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refreshscope annotated beans are not updated #1112

Open
tinah-1973 opened this issue Mar 21, 2024 · 1 comment
Open

Refreshscope annotated beans are not updated #1112

tinah-1973 opened this issue Mar 21, 2024 · 1 comment
Labels
component: parameter-store Parameter Store integration related issue status: waiting-for-feedback Waiting for feedback from issuer

Comments

@tinah-1973
Copy link

Type: Bug

Component:
spring-cloud-aws-parameter-store Version 3.1.0

Describe the bug
I am currently trying to migrate the Spring Cloud AWS dependencies from 2.4.4 to 3.1.0.
The Spring Boot Version we are using is 3.2.2

We use the AWS Parameter Store to obtain the application parameters.
Here is the configuration for that:

spring.config.import=aws-parameterstore:/EAC/ESB/APP/

spring.cloud.aws.parameterstore.region=eu-central-1

spring.cloud.aws.parameterstore.reload.strategy=refresh

spring.cloud.aws.parameterstore.reload.period=15s

So far everything fits, except the refresh of properties in @Refreshscope annotated beans isn't working.

In the debug output I see that the task runs every 15 seconds.

08:35:58.399 [spring-cloud-aws-parameterstore-ThreadPoolTaskScheduler-1] 
DEBUG io.awspring.cloud.parameterstore.ParameterStorePropertySource - Populating property retrieved from AWS Parameter Store: testCount

I set a breakpoint in ParameterStorePropertySource Line 45 to see if the parameter "testCount" contains the changed value from the parameter store.
This is the case.
But unfortunately the bean, which is using 'testCount' isn't updated.

@Configuration
@RefreshScope
public class TestConfiguration {

    @Value("${testCount}")
    private Integer testCount;

    public Integer getTestCount() {
        return this.testCount;
    }
}

@Component
@EnableScheduling
public class TestBean {

    private static final Logger LOGGER = LoggerFactory.getLogger(TestBean.class);
    @Autowired
    private TestConfiguration config;

    @Scheduled(fixedDelay = 5000)
    public void message() {
        System.out.println("The message is: " + config.getTestCount());
    }
}

Any ideas why this could be?

Do I still need the spring actuator endpoint "refresh"?

management.endpoints.web.exposure.include=refresh

I tried using it, but it didn't do anything.

@maciejwalkowiak
Copy link
Contributor

@tinah-1973 I made a sample app with Parameter Store and refresh working: https://github.com/maciej-scratches/spring-cloud-aws-gh-1003

Perhaps there's something else wrong. I am happy to take a look but please create such a repo like the one i did so that i can easily run it and see what's not working

@maciejwalkowiak maciejwalkowiak added component: parameter-store Parameter Store integration related issue status: waiting-for-feedback Waiting for feedback from issuer labels Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: parameter-store Parameter Store integration related issue status: waiting-for-feedback Waiting for feedback from issuer
Projects
None yet
Development

No branches or pull requests

2 participants