Skip to content

Are the @Retryable annotation properties cached? #68

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

Closed
BEdvin opened this issue Dec 7, 2016 · 2 comments
Closed

Are the @Retryable annotation properties cached? #68

BEdvin opened this issue Dec 7, 2016 · 2 comments

Comments

@BEdvin
Copy link

BEdvin commented Dec 7, 2016

I'm using expression by declaring properties of the annotation. My example is given below:

@Retryable(maxAttemptsExpression = "#{@instanceCounter.getCount(#accountNumber)}", backoff = @Backoff(delay = 100, maxDelay = 500))
public MyModel getMyModel(String accountNumber){
......
return myModel;
}

I want, that each time the method getMyModel is called, the bean instanceCounter also should be called.
But there was different behavior than I expected. The bean instanceCounter was called just one time, when the getMyModel method was called first time. Other time when I call the method, the bean instanceCounter is not called.

Seems like the maxAttemptsExpression property was cached after first call. And after that, value of this property is always used from cache.

It's right? There is a way to set dynamic value to this property?

@BEdvin BEdvin changed the title Is @Retryable annotation properties chached? Are the @Retryable annotation properties chached? Dec 13, 2016
@dsyer dsyer changed the title Are the @Retryable annotation properties chached? Are the @Retryable annotation properties cached? Jan 12, 2017
@dsyer
Copy link
Member

dsyer commented Jan 12, 2017

You would need to re-instantiate the bean when the configuration changed. You can do that (for instance) with @RefreshScope from Spring Cloud. Or you could create a custom RetryPolicy and inject that into an interceptor that you create yourself (and reference via the "interceptor" attribute in @Retryable).

@garyrussell
Copy link
Contributor

This will be addressed by #184

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants