Class ActorFlow
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionask(int parallelism, ActorRef<Q> ref, Duration timeout, scala.Function2<I, ActorRef<A>, Q> makeMessage) Use theaskpattern to send a request-reply message to the targetrefactor.Use theaskpattern to send a request-reply message to the targetrefactor.askWithContext(int parallelism, ActorRef<Q> ref, Duration timeout, Function2<I, ActorRef<A>, Q> makeMessage) Use theaskpattern to send a request-reply message to the targetrefactor without including the context.askWithContext(ActorRef<Q> ref, Duration timeout, Function2<I, ActorRef<A>, Q> makeMessage) Use theaskpattern to send a request-reply message to the targetrefactor without including the context.askWithStatus(int parallelism, ActorRef<Q> ref, Duration timeout, Function2<I, ActorRef<StatusReply<A>>, Q> makeMessage) Use for messages whose response is known to be apekko.pattern.StatusReply.askWithStatus(ActorRef<Q> ref, Duration timeout, Function2<I, ActorRef<StatusReply<A>>, Q> makeMessage) Use for messages whose response is known to be apekko.pattern.StatusReply.askWithStatusAndContext(ActorRef<Q> ref, Duration timeout, Function2<I, ActorRef<StatusReply<A>>, Q> makeMessage) Use for messages whose response is known to be apekko.pattern.StatusReply.
-
Constructor Details
-
ActorFlow
public ActorFlow()
-
-
Method Details
-
ask
public static <I,Q, Flow<I,A> A, askNotUsed> (ActorRef<Q> ref, Duration timeout, Function2<I, ActorRef<A>, Q> makeMessage) Use theaskpattern to send a request-reply message to the targetrefactor. If any of the asks times out it will fail the stream with aTimeoutException.Do not forget to include the expected response type in the method call, like so:
flow.via(ActorFlow.<String, AskMe, String>ask(ref, timeout, (msg, replyTo) -> new AskMe(msg, replyTo))) // or simply flow.via(ActorFlow.ask(ref, timeout, AskMe::new))otherwise
Nothingwill be assumed, which is most likely not what you want.Defaults to parallelism of 2 messages in flight, since while one ask message may be being worked on, the second one still be in the mailbox, so defaulting to sending the second one a bit earlier than when first ask has replied maintains a slightly healthier throughput.
The operator fails with an
pekko.stream.WatchedActorTerminatedExceptionif the target actor is terminated, or with anTimeoutExceptionin case the ask exceeds the timeout passed in.Adheres to the
pekko.stream.ActorAttributes.SupervisionStrategyattribute.'''Emits when''' the futures (in submission order) created by the ask pattern internally are completed
'''Backpressures when''' the number of futures reaches the configured parallelism and the downstream backpressures
'''Completes when''' upstream completes and all futures have been completed and all elements have been emitted
'''Fails when''' the passed in actor terminates, or a timeout is exceeded in any of the asks performed
'''Cancels when''' downstream cancels
-
askWithStatus
public static <I,Q, Flow<I,A> A, askWithStatusNotUsed> (ActorRef<Q> ref, Duration timeout, Function2<I, ActorRef<StatusReply<A>>, Q> makeMessage) Use for messages whose response is known to be apekko.pattern.StatusReply. When apekko.pattern.StatusReply#successresponse arrives the future is completed with the wrapped value, if apekko.pattern.StatusReply#errorarrives the future is instead failed. -
ask
public static <I,Q, Flow<I,A> A, askNotUsed> (int parallelism, ActorRef<Q> ref, Duration timeout, scala.Function2<I, ActorRef<A>, Q> makeMessage) Use theaskpattern to send a request-reply message to the targetrefactor. If any of the asks times out it will fail the stream with aTimeoutException.Do not forget to include the expected response type in the method call, like so:
flow.via(ActorFlow.<String, AskMe, String>ask(ref, timeout, (msg, replyTo) -> new AskMe(msg, replyTo))) // or simply flow.via(ActorFlow.ask(ref, timeout, AskMe::new))otherwise
Nothingwill be assumed, which is most likely not what you want.The operator fails with an
pekko.stream.WatchedActorTerminatedExceptionif the target actor is terminated, or with anTimeoutExceptionin case the ask exceeds the timeout passed in.Adheres to the
pekko.stream.ActorAttributes.SupervisionStrategyattribute.'''Emits when''' the futures (in submission order) created by the ask pattern internally are completed
'''Backpressures when''' the number of futures reaches the configured parallelism and the downstream backpressures
'''Completes when''' upstream completes and all futures have been completed and all elements have been emitted
'''Fails when''' the passed in actor terminates, or a timeout is exceeded in any of the asks performed
'''Cancels when''' downstream cancels
-
askWithStatus
public static <I,Q, Flow<I,A> A, askWithStatusNotUsed> (int parallelism, ActorRef<Q> ref, Duration timeout, Function2<I, ActorRef<StatusReply<A>>, Q> makeMessage) Use for messages whose response is known to be apekko.pattern.StatusReply. When apekko.pattern.StatusReply#successresponse arrives the future is completed with the wrapped value, if apekko.pattern.StatusReply#errorarrives the future is instead failed. -
askWithContext
public static <I,Q, Flow<Pair<I,A, Ctx> Ctx>, askWithContextPair<A, Ctx>, NotUsed> (ActorRef<Q> ref, Duration timeout, Function2<I, ActorRef<A>, Q> makeMessage) Use theaskpattern to send a request-reply message to the targetrefactor without including the context. -
askWithStatusAndContext
public static <I,Q, Flow<Pair<I,A, Ctx> Ctx>, askWithStatusAndContextPair<A, Ctx>, NotUsed> (ActorRef<Q> ref, Duration timeout, Function2<I, ActorRef<StatusReply<A>>, Q> makeMessage) Use for messages whose response is known to be apekko.pattern.StatusReply. When apekko.pattern.StatusReply#successresponse arrives the future is completed with the wrapped value, if apekko.pattern.StatusReply#errorarrives the future is instead failed. -
askWithContext
public static <I,Q, Flow<Pair<I,A, Ctx> Ctx>, askWithContextPair<A, Ctx>, NotUsed> (int parallelism, ActorRef<Q> ref, Duration timeout, Function2<I, ActorRef<A>, Q> makeMessage) Use theaskpattern to send a request-reply message to the targetrefactor without including the context.
-