ActorSource.actorRefWithBackpressure

Materialize an ActorRef<T>ActorRef[T]; sending messages to it will emit them on the stream. The source acknowledges reception after emitting a message, to provide back pressure from the source.

Actor interop operators

Dependency

This operator is included in:

sbt
libraryDependencies += "com.typesafe.akka" %% "akka-stream-typed" % "2.6.1"
Maven
<dependency>
  <groupId>com.typesafe.akka</groupId>
  <artifactId>akka-stream-typed_2.13</artifactId>
  <version>2.6.1</version>
</dependency>
Gradle
dependencies {
  compile group: 'com.typesafe.akka', name: 'akka-stream-typed_2.13', version: '2.6.1'
}

Signature

def actorRefWithBackpressure[T, Ack](ackTo: ActorRef[Ack],ackMessage: Ack,completionMatcher: PartialFunction[T, CompletionStrategy],failureMatcher: PartialFunction[T, Throwable]): Source[T, ActorRef[T]]

Description

Materialize an ActorRef<T>ActorRef[T], sending messages to it will emit them on the stream. The actor responds with the provided ack message once the element could be emitted allowing for backpressure from the source. Sending another message before the previous one has been acknowledged will fail the stream.

Reactive Streams semantics

emits when there is demand and there are messages in the buffer or a message is sent to the ActorRef

completes when the ActorRef is sent akka.actor.Status.Success

Found an error in this documentation? The source code for this page can be found here. Please feel free to edit and contribute a pull request.