【发布时间】:2018-02-13 05:49:51
【问题描述】:
使用 akka 流开始我的第一步。我有一个类似于从here 复制的图表:
val topHeadSink = Sink.head[Int]
val bottomHeadSink = Sink.head[Int]
val sharedDoubler = Flow[Int].map(_ * 2)
val g = RunnableGraph.fromGraph(GraphDSL.create(topHeadSink, bottomHeadSink)((_, _)) { implicit builder =>
(topHS, bottomHS) =>
import GraphDSL.Implicits._
val broadcast = builder.add(Broadcast[Int](2))
Source.single(1) ~> broadcast.in
broadcast.out(0) ~> sharedDoubler ~> topHS.in
broadcast.out(1) ~> sharedDoubler ~> bottomHS.in
ClosedShape
})
我可以使用g.run() 运行图表
但我怎么能阻止它?
在什么情况下我应该这样做(除了不使用 - 商业方面)?
该图包含在一个参与者中。如果 Actor 崩溃了,actor 底层的图会发生什么?它也会终止吗?
【问题讨论】:
标签: scala akka akka-stream