title: Akka flow for multiple http requests
body: <p>In a project of mine I have an akka actor for sending post requests to my google fcm server. The actor takes a list of ids and should make as many requests as there are in the list. I print out the response from the server in <code>runForeach(println(_))</code> but I only get one printout for a whole list of ids. Why does this happen?</p>
  
  <pre><code>class FCMActor(val key: String) extends Actor{
    import fcm.FCMActor._
    import akka.pattern.pipe
    import context.dispatcher
  
    private implicit def system: ActorSystem = ActorSystem()
    final implicit val materializer: ActorMaterializer = ActorMaterializer(ActorMaterializerSettings(context.system))
  
    def buildBody(id: Option[String]): String = {
      Json.obj(
        "to" -&gt; id,
        "priority" -&gt; "high",
        "data" -&gt; Json.obj("message" -&gt; "Firebase Clud Message"),
        "time_to_live" -&gt; 60
      ).toString()
    }
  
    def buildHttpRequest(body: String): HttpRequest = {
      HttpRequest(method = HttpMethods.POST,
        uri = s"/fcm/send",
        entity = HttpEntity(MediaTypes.`application/json`, body),
        headers = List(RawHeader("Authorization", s"key=$key")))
    }
  
    val connectionFlow: Flow[HttpRequest, HttpResponse, Future[Http.OutgoingConnection]] = {
      Http().outgoingConnection("fcm.googleapis.com")
    }
  
    def send(ids: List[Option[String]]) = {
  
      val httpRequests: List[HttpRequest] = ids.map(buildBody).map(buildHttpRequest)
      println(httpRequests)
  
      Source(httpRequests).via(connectionFlow).runForeach(println(_)) // &lt;&lt; here I only get one println
    }
  
    override def receive: Receive = {
      case SendToIds(ids: List[Option[String]]) =&gt;
        send(ids)
  
    }
  }
  </code></pre>