in order to add retry utility to external API calls, I am thinking of using Spring @Retryable annotation as follows:
@Service
public class MyService {
@Retryable(maxAttempts=3, value = Exception.class,
backoff = @Backoff(delay = 100, multiplier = 2))
public List<String> doCallExternalResource() {
// ...
}
}
I would like to do retries for the following errors:
1. 500 Internal Server Error
2. 502 Bad Gateway
3. 503 Service Unavailable
4. 504 Gateway Timeout
But I am not able to understand, how can I do this with the @Retryable annotation approach.
Could anyone please help here? Thanks.