Package akka.actor.typed.javadsl
Class AskPattern$
- java.lang.Object
-
- akka.actor.typed.javadsl.AskPattern$
-
public class AskPattern$ extends java.lang.Object
The ask-pattern implements the initiator side of a request–reply protocol.Note that if you are inside of an actor you should prefer
ActorContext.ask
as that provides better safety.The party that asks may be within or without an Actor, since the implementation will fabricate a (hidden)
ActorRef
that is bound to aCompletableFuture
. This ActorRef will need to be injected in the message that is sent to the target Actor in order to function as a reply-to address, therefore the argument to the ask method is not the message itself but a function that given the reply-to address will create the message.
-
-
Field Summary
Fields Modifier and Type Field Description static AskPattern$
MODULE$
Static reference to the singleton instance of this Scala object.
-
Constructor Summary
Constructors Constructor Description AskPattern$()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <Req,Res>
java.util.concurrent.CompletionStage<Res>ask(RecipientRef<Req> actor, Function<ActorRef<Res>,Req> messageFactory, java.time.Duration timeout, Scheduler scheduler)
<Req,Res>
java.util.concurrent.CompletionStage<Res>askWithStatus(RecipientRef<Req> actor, Function<ActorRef<StatusReply<Res>>,Req> messageFactory, java.time.Duration timeout, Scheduler scheduler)
The same as<Req,Res>ask(akka.actor.typed.RecipientRef<Req>,akka.japi.function.Function<akka.actor.typed.ActorRef<Res>,Req>,java.time.Duration,akka.actor.typed.Scheduler)
but only for requests that result in a response of typeStatusReply
.
-
-
-
Field Detail
-
MODULE$
public static final AskPattern$ MODULE$
Static reference to the singleton instance of this Scala object.
-
-
Method Detail
-
ask
public <Req,Res> java.util.concurrent.CompletionStage<Res> ask(RecipientRef<Req> actor, Function<ActorRef<Res>,Req> messageFactory, java.time.Duration timeout, Scheduler scheduler)
-
askWithStatus
public <Req,Res> java.util.concurrent.CompletionStage<Res> askWithStatus(RecipientRef<Req> actor, Function<ActorRef<StatusReply<Res>>,Req> messageFactory, java.time.Duration timeout, Scheduler scheduler)
The same as<Req,Res>ask(akka.actor.typed.RecipientRef<Req>,akka.japi.function.Function<akka.actor.typed.ActorRef<Res>,Req>,java.time.Duration,akka.actor.typed.Scheduler)
but only for requests that result in a response of typeStatusReply
. If the response is aStatusReply.success(T)
the returned future is completed successfully with the wrapped response. If the status response is aStatusReply.error(java.lang.String)
the returned future will be failed with the exception in the error (normally aStatusReply.ErrorMessage
).
-
-