How can I make spring @retryable configurable?

后端 未结 5 1730
误落风尘
误落风尘 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:15

    As it is explained here: https://stackoverflow.com/a/43144064

    Version 1.2 introduces the ability to use expressions for certain properties.

    So you need something like this:

    @Retryable(maxAttempts = 3, stateful = true, include = ServiceUnavailableException.class,
            exclude = URISyntaxException.class, backoff = @Backoff(delayExpression = "#{${your.delay}}" , multiplier = 2) )
    public void testThatService(String serviceAccountId)
            throws ServiceUnavailableException, URISyntaxException {
    

提交回复
热议问题