clarify sender of throttle example, #23485

* and use noSender in ActorRefSinkActor
This commit is contained in:
Patrik Nordwall 2017-08-14 16:39:34 +02:00
parent c1f247212f
commit 3637340e11
2 changed files with 5 additions and 3 deletions

View file

@ -714,6 +714,8 @@ final ActorRef throttler =
.run(materializer);
```
Note, that when using `Sink.actorRef` the sender of the original message sent to the `thottler` ActorRef will be lost and messages will arrive at the `target` with the sender set to `ActorRef.noSender`. Using this construct it is currently impossible to keep the original sender. Alternatively, you can manually specify a static sender by replacing `Sink.actorRef` with @java[`Sink.foreach(msg -> target.tell(msg, whateverSender))`]@scala[`Sink.foreach(msg => target.tell(msg, whateverSender))`]. You could also calculate a sender by inspecting the `msg`. Be cautious not to use `target.tell(msg, sender())` inside of `Sink.foreach` because the result of `sender()` is undefined or will fail when executed from within a stream.
## Akka Typed
With the new term @ref:[may change](../common/may-change.md) we will no longer have a different artifact for modules that are not

View file

@ -32,12 +32,12 @@ import akka.annotation.InternalApi
def receive = {
case OnNext(elem)
ref ! elem
ref.tell(elem, ActorRef.noSender)
case OnError(cause)
ref ! Status.Failure(cause)
ref.tell(Status.Failure(cause), ActorRef.noSender)
context.stop(self)
case OnComplete
ref ! onCompleteMessage
ref.tell(onCompleteMessage, ActorRef.noSender)
context.stop(self)
case Terminated(`ref`)
context.stop(self) // will cancel upstream