This is an AMP version of the article, its original content can be found here.
How to Retry Java Method Call on Exception
If you have a method that fails occasionally and
you want to retry it a few times before
jcabi-aspects can help.
For example, if you're downloading the following web page:
This method call will throw an exception only after three failed executions with a ten seconds interval between them.
This post explains how jcabi-aspects works with binary weaving. This mechanism integrates AspectJ with your code.
load() from the example above is called, this is what
is happening behind the scene (pseudo-code):
This approach may be very useful in the following situations (based on my experience):
Loading data from HTTP, S3, FTP, etc resources
Uploading data over the network
Fetching data through RESTful stateless API-s
The project is in GitHub.