My Java application requires repeated logic when remote calls fail. These remote calls are:
- scattered throughout the application
- belong to different classes of Remote Service.
In addition, the retry logic may have a variable retry interval and various retry attempts.
I need a generic retry () implementation that can call the appropriate method calls depending on where it is being called from. Below is a simple illustration of the code I'm looking for. I know that we can try to do this using java reflection, but is there any open source environment or source somewhere that is readable?
try { ClassA objA = remoteServiceA.call(paramA1, paramA2, ...); } catch (Exception e){ ClassA objA = (ClassA)retry(remoteService, listOfParams, ..); // generic method call } .. try { ClassB objB = remoteServiceB.call(paramB1, paramB2, ...); } catch (Exception e){ ClassA objB = (ClassB)retry(remoteService, listOfParams, ..); // generic method call }
a-sak source share