I wants to re-try the Get call to some third party API which is errored out due to some exceptions. Is there any java framework available for re-try policy instead of manually calling it again in try-catch blocks.
Have you tried adding custom java code instead of looking for new framework to achieve this? if not, try adding similar logic as mentioned below with any additional condition as per your requirement & it will work.
int retryCount = 3;
int statusCode = 0;
HttpClient httpclient = new HttpClient(httpConnectionManager);
GetMethod getMethod = new GetMethod("API End Point");
statusCode = httpclient.executeMethod(getMethod);
}while(statusCode!= 200 && retryCount!= 0); //break loop if API return 200 status code OR 3 retry count completed
Hope this helps!
There are a couple of libraries like that: they are mostly connected with some resilience packages, but I wouldn't bother in this case (although maybe you're interested in something like resilience4j, but in my opinion that's very large framework and you need some library, like this Guava Retrying
I am using it from time to time to my scripts that do some automation on AEM instances, and it does it very well. I am done with Apache HttpClient for years now in favor of some simple APIs like OkHttp or so, so I can't give you a code snippet just now. You should check documentation, it's pretty simple fluent-API to follow.
There are a number Java frameworks around, which can do that. But I wouldn't look for the inclusion of a new framework if you want write that with a handful of lines java code 🙂
(You can put into a Sling Job; if this one terminates with an exception, it is retried... But I am not sure if that fits into your application design.)
you can use scheduler to call third party api with frequent intervals or as per schedule.
If the process stops with the error / exception, the same can not run again.