v.0.3.0
CompletableFuture compatibility
Added two new ActorRef ask methods returning CompletableFuture
:
<R> CompletableFuture<R> ask(Function<T, R> action);
<R> CompletableFuture<R> ask(BiConsumer<T, Consumer<R>> action);
These methods pass the actor call result to the CompletableFuture returned from the method. In case of exception occuring during actor call, the exception is also passed to the CompletableFuture (the actor's exception handler is not triggered in that case).
Users are now able to process exceptions coming from actor calls:
primeNumberDetectorActor.askAnsweringFuture(primeNumberDetector -> primeNumberDetector.isNumberPrime(5))
.thenApply(isPrime -> System.out.println("5 is prime? "+isPrime))
.exceptionally(ex -> ex.printStackTrace());