I\'m writing some reconnect logic to periodically attempt to establish a connection to a remote endpoint which went down. Essentially, the code looks like this:
If you are using java 8, this may helps.
import java.util.function.Supplier;
public class Retrier {
public static Object retry(Supplier function, int retryCount) throws Exception {
while (0 {
System.out.println(5/0);
return null;
}, 5);
} catch (Exception e) {
System.out.println("Exception : " + e.getMessage());
}
}
}
Thanks,
Praveen R.