如何获得源的 ActorRef?

How can I get an ActorRef of a Source?

假设我有一个来源:

val source = Source(List(1,2,3))

如何像演员一样给消息来源发消息?

sourceActor ! 4

你不能像那样使用简单的基于集合的源代码。您需要另一个,例如 Source.actorRefSource.queue。请记住,使用 Source.actorRef 不会给您带来背压,并且通过网络远程发送的消息可能会丢失(由于参与者通信的最多一次传递语义)。

另外,Akka 文档中有 an entire section 关于集成 actors 的内容。