Reputation: 2167
I want to create a graph with a Broadcast
and a Concat
in Akka Stream, but the following code doesn't work. I want to know why it doesn't work.
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()
My expected output is
1
2
3
1
2
3
But, actually, nothing is outputted. I would like you to tell why my code doesn't work.
Upvotes: 0
Views: 393
Reputation: 26589
Broadcast can only work if its downstreams all have demand, and concat only demands from one upstream at a time (otherwise you'd want to have merge etc), and thus broadcast cannot broadcast anything.
Upvotes: 2