I am working on a JAVA program that has to run a very simple workflow made of 5 tasks and executed one by one:
Workflow: Task(A) -> Task(B) -> Task(C) -> Task(D) -> Task(E)
------- -------
This workflow is launched, every time that my program receives an input
The only difficulty I have is that the workflow can block at 3rd and 4th tasks
Indeed,
Task(C)
calls/usesService(C)
that can be momentarily downTask(D)
calls/usesService(D)
that also can be momentarily down
Here is the behavior that I want to reach:
- when a service is down (
Service(C)
orService(D)
) the current workflow should interrupt - when a new input is received while a service is down (
Service(C)
orService(D)
), all tasks of the workflow should be run until the blocked task - when a down service becomes up once again (and the task unblocks), all interrupted executions should immediately restart
For sure I can develop my own framework to reach what I need but I would like to use an existing framework (preferably in the JDK) in order to benefit from something robust and proven
I found that since Java 8 (very old: sorry for not being up to date) Java provides CompletableFuture
that seems to be very powerful… however, I’m not yet very comfortable with it
- is it possible to reach my target behavior with JAVA
CompletableFuture
? - or should I use a different Framework? If so, which one?
- whatever is the answer, I would strongly appreciate light examples
Thank you for helping