英文:
Exit before all attempts in Spring Retryable
问题
我已经在Spring Boot中编写了一个可重试的部分。它将重试5次,并且重试间隔为5秒。如果满足某个条件,我还想在进行5次迭代之前退出。就像这样:
@Retryable(value = {SomeException.class}, maxAttempts = 5, backoff = @Backoff(delay = 5000))
public void checkForProcessed() throws SomeException {
if (someCondition) {
// 在重试5次之前退出可重试逻辑。
}
}
所以假设在第三次迭代中满足了条件,它不应再重试2次,而应在第三次迭代中退出。
英文:
I have written a Retryable in Spring boot. It will retry 5 times, and with a backoff of 5 seconds. I would also like to exit before 5 iterations, if some condition is met. It's like
@Retryable(value = {SomeException.class}, maxAttempts = 5, backoff = @Backoff(delay = 5000))
public void checkForProcessed() throws SomeException {
if(someCondition) {
//come out of the retryable before retrying for 5 times.
}
}
So let's say the condition is met in the third iteration, it should not retry for 2 more times, and should exit in the 3rd iteration itself
答案1
得分: 0
抛出 SomeOtherException
(不可重试的异常)。
英文:
Throw SomeOtherException
(which is not retryable).
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论