Package io.camunda.zeebe.util.sched
Interface AsyncContext
public interface AsyncContext
-
Method Summary
-
Method Details
-
async
Use with careNote that the following pattern does not work
void fetch(AsyncContext ctx) { ActorFutureThe problem is that now, if another component is awaiting on future, both this component and the actor.runOnCompletion are waiting on the same future, and there is no guaranteed order in which these are invoked, which could lead to unexpected behaviour (e.g. the stream processor moves to the next processing stage before the callback runs).future = asyncApi.fetchData(); actor.runOnCompletion(future, (someData, err) -> { // do something }); ctx.async(future); } You can refactor it to this:
void process(AsyncContext ctx) { ActorFuturefuture = asyncApi.fetchData(); ActorFuture whenProcessingDone = new CompletableActorFuture(); actor.runOnCompletion(future, (someData, err) -> { // do something whenProcessingDone.complete(null); }); ctx.async(whenProcessingDone); } - Parameters:
future- the future to pass
-