Java – spring @ retryable for specific conditions

Can I try again based on some conditions? If I use retryable for annotation, it will retry based on some exceptions, but if the exception is caught and the corresponding conditions are met, I want to retry

@Retryable(value={MyException.class},maxAttempts=2)
public myMethod(Request request){

    try{
        doSomething();
    } Catch(Exception ex){
        throw new MyException();
    }

}

In the above request, I have a flag, isretryrequired. If it is true and myexception is caught, then I want to try again

Solution

Not directly in comments; You need to customize the retry policy through the interceptor properties

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>