`Sink.actorRef` with `sender`

Say I have an actor that does this:

  override def receive: Receive = {
      case _ => Source(List(1, 2, 3)).runWith(Sink.actorRef(recipient, Status.Success))

The sender of 1, 2, 3 will be deadLetters. How can I make parent actor that runs the graph the sender of the messages of Sink.actorRef?

Found the solution:

Instead of

Source(List(1, 2, 3)).runWith(Sink.actorRef(recipient, Status.Success))

do:

Source(List(1, 2, 3))
    .concat(Source.single(Status.Success))
    .recover({ case e => Status.Failure(e) })
    .runForeach(recipient ! _)

I’m keeping monologue here, asking questions and then answering them myself…

1 Like