title: Akka/Scala: onSuccess for multiple asks to different actor
body: <p>I'm trying to make an async call to different sub-actors, such as:</p>
  
  <pre><code>A ---&gt; B ---&gt; C
          \---&gt; D
  </code></pre>
  
  <p>Actor A sends a request message to Actor B and B send two task messages to C and D, when C and D send the results back, B merge the results up and  send it back to the A.</p>
  
  <p>I was trying to use ask pattern and onSuccess to solve this:</p>
  
  <pre><code>class B(fakeInterface: String, subInterface: Array[ActorRef]) extends Actor {
  
  val subCount = subInterface.length
  var finishCount = 0
  
  def receive = {
    case reqMsg(msg) =&gt;
  
      if (subInterface.length == 0){
        sender ! DoneMessage(msg)
      } else {
        implicit val timeout = Timeout(5 minutes)
        val composedFutures = subInterface map { x =&gt;
          (x ? DoItMessage(msg)).mapTo[DoneMessage]
        }
  
        val allResult = Future.sequence(composedFutures)
        allResult.onSuccess {
          case _ =&gt; sender ! DoneMessage(msg)
        }
      }
    }
  }
  </code></pre>
  
  <p>But the code above does not compile at all, I got three error:</p>
  
  <pre><code>[error] inferred type arguments [dummy.DoneMessage,Array] do not conform to method sequence's type parameter bounds [A,M[_] &lt;: TraversableOnce[_]]
  [error]         val allResult = Future.sequence(composedFutures)
  [error]                                ^
  [error]  type mismatch;
  [error]  found   : Array[scala.concurrent.Future[dummy.DoneMessage]]
  [error]  required: M[scala.concurrent.Future[A]]
  [error]         val allResult = Future.sequence(composedFutures)
  [error]                                         ^
  [error]  Cannot construct a collection of type M[A] with elements of type A based on a collection of type M[scala.concurrent.Future[A]].
  [error]         val allResult = Future.sequence(composedFutures)
  [error]                                        ^
  [error] three errors found
  </code></pre>
  
  <p>How can I fix this? Or is there a more proper way to solve this scenario?</p>