I am facing with a similar problem currently and I couldn't found elegant solution for this. Below is a work around I think might help you:
@Retryable(value = {SocketTimeoutException.class},
backoff = @Backoff(delayExpression = "${retry.delay:10000}"),
maxAttemptsExpression = "${retry.max-attempts:4}")
void function1(){
//do actual work here
}
@Retryable(value = {AmazonServiceException.class},
backoff = @Backoff(delayExpression = "${retry.delay:100}"),
maxAttemptsExpression = "${retry.max-attempts:4}")
void function2(){
function1(); // call function1
}
Call function2
to execute your logic. Main idea here is to call another function from with in the first function and these two functions are configured with different BackOff delays.
There are situations where this can create some problem in terms for max attempts value. Specifically, in worstcase senario there can be total of 8 attempts of retry(4 + 4).