Class AskPattern$
java.lang.Object
org.apache.pekko.actor.typed.javadsl.AskPattern$
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 a
CompletableFuture. 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
FieldsModifier and TypeFieldDescriptionstatic final AskPattern$Static reference to the singleton instance of this Scala object. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<Req,Res> CompletionStage<Res> ask(RecipientRef<Req> actor, Function<ActorRef<Res>, Req> messageFactory, Duration timeout, Scheduler scheduler) <Req,Res> CompletionStage<Res> askWithStatus(RecipientRef<Req> actor, Function<ActorRef<StatusReply<Res>>, Req> messageFactory, Duration timeout, Scheduler scheduler) The same as<Req,Res>ask(org.apache.pekko.actor.typed.RecipientRef<Req>,org.apache.pekko.japi.function.Function<org.apache.pekko.actor.typed.ActorRef<Res>,Req>,java.time.Duration,org.apache.pekko.actor.typed.Scheduler)but only for requests that result in a response of typepekko.pattern.StatusReply.
-
Field Details
-
MODULE$
Static reference to the singleton instance of this Scala object.
-
-
Constructor Details
-
AskPattern$
public AskPattern$()
-
-
Method Details
-
ask
public <Req,Res> CompletionStage<Res> ask(RecipientRef<Req> actor, Function<ActorRef<Res>, Req> messageFactory, Duration timeout, Scheduler scheduler) -
askWithStatus
public <Req,Res> CompletionStage<Res> askWithStatus(RecipientRef<Req> actor, Function<ActorRef<StatusReply<Res>>, Req> messageFactory, Duration timeout, Scheduler scheduler) The same as<Req,Res>ask(org.apache.pekko.actor.typed.RecipientRef<Req>,org.apache.pekko.japi.function.Function<org.apache.pekko.actor.typed.ActorRef<Res>,Req>,java.time.Duration,org.apache.pekko.actor.typed.Scheduler)but only for requests that result in a response of typepekko.pattern.StatusReply. If the response is apekko.pattern.StatusReply#successthe returned future is completed successfully with the wrapped response. If the status response is apekko.pattern.StatusReply#errorthe returned future will be failed with the exception in the error (normally apekko.pattern.StatusReply.ErrorMessage).
-