- @Retryable
/**
* 默认重试三次
*/
@Retryable(RetryException.class)
public void update() {
log.info("update");
throw new RetryException("更新失败");
}
- RetryTemplate
RetryTemplate template = RetryTemplate.builder()
.maxAttempts(3)
.fixedBackoff(1000)
.retryOn(RetryException.class)
.build();