How can I make spring @retryable configurable?

后端 未结 5 1737
误落风尘
误落风尘 2021-02-13 05:46

I have this piece of code

@Retryable(maxAttempts = 3, stateful = true, include = ServiceUnavailableException.class,
        exclude = URISyntaxException.class, b         


        
5条回答
  •  眼角桃花
    2021-02-13 06:03

    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

提交回复
热议问题