@Override
public void act2() {
throwException();
}
@Override
public void act3() {
Thread.sleep(10000);
throwException();
}
Promise<Void> promise1 = Async.procedure(sampleActivity::act2);
Promise<Void> promise2 = Async.procedure(sampleActivity::act3);
List<Promise<Void>> promises = new ArrayList<>();
promises.add(promise1);
promises.add(promise2);
try {
Promise.allOf(promises).get();
} catch (Exception e) {
System.out.println("Exception encountered");
}
Workflow method shown above. Upon workflow execution, act2 throws an error which is caught in the catch block and workflow gets completed. act3 ,on the other hand, sleeps for 10 seconds post which throws an error. The workflow, as can be seen in the screenshot, is marked completed but act3 still stays in pending.
Queries -
- What happens to pending promises when one of the promises throws exception?
- When a workflow gets completed, what happens to any pending activities?