Package akka.stream.typed.scaladsl
Class ActorSink
- java.lang.Object
-
- akka.stream.typed.scaladsl.ActorSink
-
public class ActorSink extends java.lang.Object
Sends the elements of the stream to the givenActorRef
. If the target actor terminates the stream will be canceled. When the stream is completed successfully the givenonCompleteMessage
will be sent to the destination actor. When the stream is completed with failure a the throwable that was signaled to the stream is adapted to the Actors protocol usingonFailureMessage
and then then sent to the destination actor.It will request at most
maxInputBufferSize
number of elements from upstream, but there is no back-pressure signal from the destination actor, i.e. if the actor is not consuming the messages fast enough the mailbox of the actor will grow. For potentially slow consumer actors it is recommended to use a bounded mailbox with zeromailbox-push-timeout-time
or use a rate limiting stage in front of thisSink
.
-
-
Constructor Summary
Constructors Constructor Description ActorSink()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Sink<T,NotUsed>
actorRef(ActorRef<T> ref, T onCompleteMessage, scala.Function1<java.lang.Throwable,T> onFailureMessage)
static <T,M,A>
Sink<T,NotUsed>actorRefWithAck(ActorRef<M> ref, scala.Function2<ActorRef<A>,T,M> messageAdapter, scala.Function1<ActorRef<A>,M> onInitMessage, A ackMessage, M onCompleteMessage, scala.Function1<java.lang.Throwable,M> onFailureMessage)
Sends the elements of the stream to the givenActorRef
that sends back back-pressure signal.
-
-
-
Method Detail
-
actorRef
public static <T> Sink<T,NotUsed> actorRef(ActorRef<T> ref, T onCompleteMessage, scala.Function1<java.lang.Throwable,T> onFailureMessage)
-
actorRefWithAck
public static <T,M,A> Sink<T,NotUsed> actorRefWithAck(ActorRef<M> ref, scala.Function2<ActorRef<A>,T,M> messageAdapter, scala.Function1<ActorRef<A>,M> onInitMessage, A ackMessage, M onCompleteMessage, scala.Function1<java.lang.Throwable,M> onFailureMessage)
Sends the elements of the stream to the givenActorRef
that sends back back-pressure signal. First element is alwaysonInitMessage
, then stream is waiting for acknowledgement messageackMessage
from the given actor which means that it is ready to process elements. It also requiresackMessage
message after each stream element to make backpressure work.If the target actor terminates the stream will be canceled. When the stream is completed successfully the given
onCompleteMessage
will be sent to the destination actor. When the stream is completed with failure - result ofonFailureMessage(throwable)
function will be sent to the destination actor.- Parameters:
ref
- (undocumented)messageAdapter
- (undocumented)onInitMessage
- (undocumented)ackMessage
- (undocumented)onCompleteMessage
- (undocumented)onFailureMessage
- (undocumented)- Returns:
- (undocumented)
-
-