I have this piece of code
@Retryable(maxAttempts = 3, stateful = true, include = ServiceUnavailableException.class,
exclude = URISyntaxException.class, backoff = @Backoff(delay = 1000, multiplier = 2) )
public void testThatService(String serviceAccountId)
throws ServiceUnavailableException, URISyntaxException {
//some implementation here }
Is there a way I can make the maxAttempts , delay and multiplier configurable using @Value? Or is there any other approach to make such fields inside annotations configurable?
with the release of Spring-retry version 1.2, it's possible. @Retryable can be configured using SPEL.
@Retryable(
value = { SomeException.class,AnotherException.class },
maxAttemptsExpression = "#{@myBean.getMyProperties('retryCount')}",
backoff = @Backoff(delayExpression = "#{@myBean.getMyProperties('retryInitalInterval')}"))
public void doJob(){
//your code here
}
For more details refer: https://github.com/spring-projects/spring-retry/blob/master/README.md