diff --git a/akka-docs/src/main/paradox/scala/project/migration-guide-2.4.x-2.5.x.md b/akka-docs/src/main/paradox/scala/project/migration-guide-2.4.x-2.5.x.md index 152aa513ac..c45d127ebb 100644 --- a/akka-docs/src/main/paradox/scala/project/migration-guide-2.4.x-2.5.x.md +++ b/akka-docs/src/main/paradox/scala/project/migration-guide-2.4.x-2.5.x.md @@ -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 diff --git a/akka-stream/src/main/scala/akka/stream/impl/ActorRefSinkActor.scala b/akka-stream/src/main/scala/akka/stream/impl/ActorRefSinkActor.scala index 93ad580c59..a03ded1458 100644 --- a/akka-stream/src/main/scala/akka/stream/impl/ActorRefSinkActor.scala +++ b/akka-stream/src/main/scala/akka/stream/impl/ActorRefSinkActor.scala @@ -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