在下面的方法中,我使用重试逻辑,我期望第一次尝试应该失败,第二次尝试应该成功保存。
public Record saveRecord(Record Record) {
try {
return vcRetry.execute(
context -> {
System.out.println("Inside the Method");
if(context.getRetryCount()==0)
throw new RuntimeException("Something went wrong");
return RecordDao.save(Record);
});
上面的方法只执行了一次,我已经做了一些调试,vcRetry模板属性是正确的:
请帮忙为什么它第二次不回来?
最佳答案
我认为,我们会重试特定类型的异常。尝试下面的链接,
关于java - RetryTemplate 只执行一次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59711551/