I have to write a Java client code for a webservice published by some other party.
In that client code I have to give option for retry for specified number of times if any timeout occurs.
In webservice call I have passed non persisten objects, so in retry process I think these
objects should be saved.
A code sample would be very helpful.
解决方案
AOP and Java annotations is the right way to do it. I would recommend a read-made mechanism from jcabi-aspects (I'm a developer):
import com.jcabi.aspects.RetryOnFailure;
@RetryOnFailure(attempts = 4)
public String load(URL url) {
// sensitive operation that may throw an exception
return url.openConnection().getContent();
}