I have to call a critical API over a network (which makes it unreliable) many number of times in a go, many times a day. If the API fails to respond (timeout) or returns an error (because that server is in turn calling other unreliable third parties) i have to notify them about the error and then call the original API again.
Here, the error notifying may fail too and i will have to retry notifying error until i succeed. After which i can call the original API again.
I wanted to frame this using CompletableFuture. Is it a right choice of library for this kind of code? Or should i put a try catch loop in an infinite loop packed in a Runnable and execute it? Will CompletableFuture be an overkill? Is there any other alternative?