我的问题涉及到:Accessing the underlying ActorRef of an akka stream Source created by Source.actorRef 有一些差异:
我找不到让actorRef将消息发送到Source持有的Actor Publisher实例的方法。
def run(implicit system: ActorSystem) = { import system.dispatcher implicit val materializer = ActorMaterializer() val source = Source.actorPublisher[TestRequest](TestActor.props).map { request => request.event } //Implementation in subpackage val sinkLevel1 = Sinks.sinkLevel1 val sinkLevel2 = Sinks.sinkLevel2 //Implementation in subpackage val stageTriage = FlowStages.stageTriage val stageEvalProcess1 = FlowStages.stageEvalProcess1 val stageEvalProcess2 = FlowStages.stageEvalProcess2 val pipeline = FlowGraph.closed(){ implicit builder => import FlowGraph.Implicits._ val stageDispatchByRuleLevels = builder.add(Broadcast[TriagedSystemEvent](2)) source ~> stageTriage ~> stageDispatchByRuleLevels stageDispatchByRuleLevels ~> stageEvalProcess1 ~> sinkLevel1 stageDispatchByRuleLevels ~> stageEvalProcess2 ~> sinkLevel2 } pipeline.run() }
感谢您的帮助!
奥利弗
答案 0 :(得分:1)
根据诺亚在链接问题中的回答,如果你添加
val ref = pipeline.run()
然后您可以向ref发送消息,例如
ref ! ...