watch
Watch a specific ActorRef
and signal a failure downstream once the actor terminates.
Signature¶
Description¶
Watch a specific ActorRef
and signal a failure downstream once the actor terminates. The signaled failure will be an WatchedActorTerminatedException
.
Example¶
An ActorRef
can be can be watched and the stream will fail with WatchedActorTerminatedException
when the actor terminates.
sourceval ref: ActorRef = someActor()
val flow: Flow[String, String, NotUsed] =
Flow[String].watch(ref).recover {
case _: WatchedActorTerminatedException => s"$ref terminated"
}
sourcefinal ActorRef ref = someActor();
Flow<String, String, NotUsed> flow =
Flow.of(String.class)
.watch(ref)
.recover(
org.apache.pekko.stream.WatchedActorTerminatedException.class,
() -> ref + " terminated");
Reactive Streams semantics¶
emits when upstream emits
backpressures when downstream backpressures
completes when upstream completes
1.1.3