How to wait broadcast results with akka-stream? <p>I tried akka-stream 2.4.8 with the following sample code:</p> <pre><code>import scala.concurrent._ import scala.concurrent.duration._ import akka.actor.ActorSystem import akka.stream._ import akka.stream.scaladsl._ class AkkaStreamSample01 { def doit = { implicit val actorSystem = ActorSystem("AkkaStreamSample00") implicit val materializer = ActorMaterializer( ActorMaterializerSettings(actorSystem).withDebugLogging(true).withSupervisionStrategy { ex: Throwable =&gt; println(s"ex: ${ex.getClass}"); Supervision.Stop // ; throw ex } ) try { val source = Source.single( 123L ) val ff01 = Flow[Long].map { x =&gt; println(s"begin: heavy: ff01 with arg = $x") (Seq.empty[String] /: ("+" * 1234 * 9999)) { (seq, x) =&gt; x.toString +: seq } // val ss: String = null; ss.size println(s"end: heavy: ff01 with arg = $x") x }.async val ff02 = Flow[Long].map { x =&gt; println(s"begin: light: ff02 with arg = $x") (Seq.empty[String] /: ("+" * 11 * 11)) { (seq, x) =&gt; x.toString +: seq } println(s"end: light: ff02 with arg = $x") x }.async val ff03 = Flow[Long].map { x =&gt; println(s"begin: heavy: ff03 with arg = $x") (Seq.empty[String] /: ("+" * 1111 * 9999)) { (seq, x) =&gt; x.toString +: seq } println(s"end: heavy: ff03 with arg = $x") x }.async val sink = Sink.seq[Long] val g = RunnableGraph.fromGraph(GraphDSL.create(sink) { implicit builder =&gt; sinkkk =&gt; import GraphDSL.Implicits._ val bro = builder.add(Broadcast[Long](3)) val merge = builder.add(Merge[Long](3)) source ~&gt; bro.in bro.out(0) ~&gt; ff01 ~&gt; merge bro.out(1) ~&gt; ff02 ~&gt; merge bro.out(2) ~&gt; ff03 ~&gt; merge merge.out ~&gt; sinkkk // Sink.seq[Long] ClosedShape }) println(s"... begin ... $getClass") Await.result(g.run, 30.seconds) println(s"... end ...") // hope to print out after completion } finally { println("terminating") actorSystem.terminate } // TimeUnit.SECONDS.sleep(10) } } </code></pre> <p>output:</p> <pre><code>... begin ... begin: heavy: ff01 with arg = 123 begin: heavy: ff03 with arg = 123 begin: light: ff02 with arg = 123 end: light: ff02 with arg = 123 ... end ... terminating end: heavy: ff03 with arg = 123 end: heavy: ff01 with arg = 123 </code></pre> <p>How to wait broadcast results? I hope the following output:</p> <pre><code>... begin ... begin: heavy: ff01 with arg = 123 begin: heavy: ff03 with arg = 123 begin: light: ff02 with arg = 123 end: light: ff02 with arg = 123 end: heavy: ff03 with arg = 123 end: heavy: ff01 with arg = 123 ... end ... terminating </code></pre> <p>thanks.</p> <hr> <p>[entry point] object Boot extends App { new AkkaStreamSample01().doit }</p> <p>[java -version] java version "1.8.0_102"</p> <p>[build.sbt]</p> <pre><code>name := "sbt-akka-streams-sample" scalaVersion := "2.11.8" libraryDependencies ++= Seq( // "com.typesafe.akka" % "akka-stream_2.11" % "2.4.4" "com.typesafe.akka" % "akka-stream_2.11" % "2.4.8" ) </code></pre>