我正在使用 Java 8 Spring 启动。我有以下方法。
public hello() {
try {
// send message
}
catch(HttpClientErrorException e) {
if (e.getRawStatusCode() == 401) {
// I need to retry the same hello() method for three times as in 10sec, 20sec and 25sec.
}
}
}
Run Code Online (Sandbox Code Playgroud)
我需要调用相同的方法三次,以便在遇到 catch 块时重试。我怎样才能异步执行此操作?
我找到了下面的代码,但它不起作用。
@Retryable( value = {RestClientException.class}, maxAttempts = 3, backoff = @Backoff(3000))
Run Code Online (Sandbox Code Playgroud)
感谢你的帮助。