0
我想在Akka Stream中創建一個包含Broadcast
和Concat
的圖,但以下代碼不起作用。我想知道爲什麼它不起作用。廣播和Concat在Akka Stream中不工作
val src = Source(1 to 3)
val sink = Sink.foreach(println)
RunnableGraph.fromGraph(GraphDSL.create() { implicit b =>
import GraphDSL.Implicits._
val bcast = b.add(Broadcast[Int](2))
val concat = b.add(Concat[Int](2))
src ~> bcast ~> concat ~> sink
bcast ~> concat
ClosedShape
}).run()
我的預期輸出是
1
2
3
1
2
3
但是,實際上,沒有輸出。我想告訴你爲什麼我的代碼不起作用。
廣播只有在其下行流都有需求時才能工作,並且一次只能從一個上行鏈路接收請求(否則你想要合併等),因此廣播不能廣播任何內容。 –
非常感謝。我明白原因。 – redstone