title: How do you deal with futures and mapAsync in Akka Flow?
body: <p>I built a akka graph DSL defining a simple flow. But the flow f4 takes 3 seconds to send an element while f2 takes 10 seconds. </p>
  
  <p>As a result, I got : 3, 2, 3, 2. But, this is not what I want. As f2 takes too much time, I would like to get : 3, 3, 2, 2. Here's the code...</p>
  
  <pre><code>implicit val actorSystem = ActorSystem("NumberSystem")
  implicit val materializer = ActorMaterializer()
  
  val g = RunnableGraph.fromGraph(GraphDSL.create() { implicit builder: GraphDSL.Builder[NotUsed] =&gt;
    import GraphDSL.Implicits._
    val in = Source(List(1, 1))
    val out = Sink.foreach(println)
  
    val bcast = builder.add(Broadcast[Int](2))
    val merge = builder.add(Merge[Int](2))
  
  
  
    val yourMapper: Int =&gt; Future[Int] = (i: Int) =&gt; Future(i + 1)
    val yourMapper2: Int =&gt; Future[Int] = (i: Int) =&gt; Future(i + 2)
  
    val f1, f3 = Flow[Int]
    val f2= Flow[Int].throttle(1, 10.second, 0, ThrottleMode.Shaping).mapAsync[Int](2)(yourMapper)
    val f4= Flow[Int].throttle(1, 3.second, 0, ThrottleMode.Shaping).mapAsync[Int](2)(yourMapper2)
  
    in ~&gt; f1 ~&gt; bcast ~&gt; f2 ~&gt; merge ~&gt; f3 ~&gt; out
    bcast ~&gt; f4 ~&gt; merge
    ClosedShape
  })
  g.run()
  </code></pre>
  
  <p>So where am I going wrong ? With future or mapAsync ? or else ...
  Thanks </p>