Guest User

Untitled

a guest
Jul 11th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. @Service
  2. public class TestService {
  3.  
  4. @Retryable(value = {SomeException.class, MyException.class},
  5. maxAttempts = 3,backoff = @Backoff(2000))
  6. public void retryWhenException() {
  7. try{
  8. // perform operation that can fail
  9. }catch(SomeException se){
  10. // will be retried
  11. throw se;
  12. }catch(MyException me){
  13. // will be retried
  14. throw me;
  15. }catch(Exception e){
  16. // will not be retried
  17. throw e;
  18. }
  19. }
  20.  
  21. @Recover
  22. public void recover(SomeException exception) {
  23. // recover from SomeException
  24. }
  25. }
Add Comment
Please, Sign In to add comment