我在Spring Boot 1.5.9.RELEASE上使用了编译’org.springframework.retry:spring-retry:1.2.2.RELEASE’.
配置为重试我的方法,它运作良好:
@Retryable(value = { IOException.class },maxAttempts = 5,backoff = @Backoff(delay = 500))
public void someMethod(){...}
重试发生时如何输出某些特定消息?
最佳答案
通过代码查看org.springframework.retry.support.RetryTemplate执行重试逻辑以重试操作.此模板仅记录以下简单内容:
o.s.retry.support.RetryTemplate : Retry: count=0
o.s.retry.support.RetryTemplate : Checking for rethrow: count=1
o.s.retry.support.RetryTemplate : Retry: count=1
o.s.retry.support.RetryTemplate : Checking for rethrow: count=2
o.s.retry.support.RetryTemplate : Retry: count=2
o.s.retry.support.RetryTemplate : Checking for rethrow: count=3
o.s.retry.support.RetryTemplate : Retry Failed last attempt: count=3
如果要记录特定的异常,可以捕获异常日志并重新抛出.不幸的是,据我所知,没有办法在框架内记录自定义消息.
原文地址:https://www.jb51.cc/spring/431701.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。