Spring Retry with Transactional

前端 未结 4 1566
余生分开走
余生分开走 2021-01-01 13:57

Is Spring Retry guaranteed to work with Spring\'s @Transactional annotation?

Specifically, I\'m trying to use @Retryable for optimistic loc

4条回答
  •  离开以前
    2021-01-01 14:40

    By default Spring Retry builds advice with the same LOWEST_PRECEDENCE order - take a look at the RetryConfiguration. However, there is a pretty simple way to override this order:

    @Configuration
    public class MyRetryConfiguration extends RetryConfiguration {
       @Override
       public int getOrder() {
          return Ordered.HIGHEST_PRECEDENCE;
       }
    }
    

    Make sure to omit the @EnableRetry annotation to avoid default RetryConfiguration be taken into account.

提交回复
热议问题