Is there possible to return the next behavior depending on async operation ? Here is an example
Behaviors.receive(Command.class)
.onMessage(Move.class, (context, message) -> {
CompletionStage<Behaviors<Move>> nextBehavior = doSomethingAsync().thenApply(result -> {
if (result != null)
return moveToLeftBehavior();
else
return moveToRightBehavior();
});
return nextBehavior; // I can return this
})
.build();