I couldn’t find an example online but it seems like when we call multiple async activities there is no elegant way of knowing which one has completed first.In a normal case I would use Java CompletionService which gives the first Future that completed. But in the case of Temporal I only see running a simply for loop and doing a synchronous wait on the promise.get()
You can use
Promise.anyOf(promiseList);
where promiseList is a List<Promise>
which can contain your Async.function calls, for example:
promiseList.add(Async.function(myActivities::doSomething, inputA, inputB));
…
Hope this helps.
this returns the first completed ones right?
1 Like