Last active
July 23, 2017 11:33
-
-
Save mchernyavskaya/fbb53c6ec380f59119f7f06f39914f1a to your computer and use it in GitHub Desktop.
Spring Retry - create strategy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
We want to retry on IOException only. | |
Other Exceptions won't be retried. | |
IOException will be retried three times, counting the initial attempt. | |
*/ | |
final ExceptionClassifierRetryPolicy exRetryPolicy = new ExceptionClassifierRetryPolicy(); | |
exRetryPolicy.setPolicyMap(new HashMap<Class<? extends Throwable>, RetryPolicy>() {{ | |
put(IOException.class, new SimpleRetryPolicy(3)); | |
put(Exception.class, new NeverRetryPolicy()); | |
}}); | |
retryTemplate.setRetryPolicy(exRetryPolicy); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment