clarify sender of throttle example, #23485
* and use noSender in ActorRefSinkActor
This commit is contained in:
parent
c1f247212f
commit
3637340e11
2 changed files with 5 additions and 3 deletions
|
|
@ -714,6 +714,8 @@ final ActorRef throttler =
|
||||||
.run(materializer);
|
.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
|
## 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
|
With the new term @ref:[may change](../common/may-change.md) we will no longer have a different artifact for modules that are not
|
||||||
|
|
|
||||||
|
|
@ -32,12 +32,12 @@ import akka.annotation.InternalApi
|
||||||
|
|
||||||
def receive = {
|
def receive = {
|
||||||
case OnNext(elem) ⇒
|
case OnNext(elem) ⇒
|
||||||
ref ! elem
|
ref.tell(elem, ActorRef.noSender)
|
||||||
case OnError(cause) ⇒
|
case OnError(cause) ⇒
|
||||||
ref ! Status.Failure(cause)
|
ref.tell(Status.Failure(cause), ActorRef.noSender)
|
||||||
context.stop(self)
|
context.stop(self)
|
||||||
case OnComplete ⇒
|
case OnComplete ⇒
|
||||||
ref ! onCompleteMessage
|
ref.tell(onCompleteMessage, ActorRef.noSender)
|
||||||
context.stop(self)
|
context.stop(self)
|
||||||
case Terminated(`ref`) ⇒
|
case Terminated(`ref`) ⇒
|
||||||
context.stop(self) // will cancel upstream
|
context.stop(self) // will cancel upstream
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue