title: Akka Stream connect to multiple sinks
body: <p>I have implemented a custom component in akka stream which takes elements as input, groups and merges them based on a key and sends them out through one of a dozen outlets. You can think of this component as a kind of GroupBy component which does not partition the flow into subflows, but actual flows. In addition to partitioning incoming elements, it merges them into one element, i.e. there is some buffering happening inside the component such that 1 element in does not necessarily mean 1 element out through an outlet.</p>
  
  <p>Below is a simplified implementation of said component.</p>
  
  <pre><code>class CustomGroupBy[A,B](k: Int, f: A =&gt; Int) extends GraphStage[FlowShape[B, B]] {
  
    val in = Inlet[A]("CustomGroupBy.in")
    val outs = (0 until k).map(i =&gt; Outlet[B](s"CustomGroupBy.$i.out"))
  
    override val shape = new AmorphousShape(scala.collection.immutable.Seq(in), outs)
  
    /* ... */
  }
  </code></pre>
  
  <p>I now what to connect each outlet of that component to a different Sink and combine the materialized value of all these sinks.</p>
  
  <p>I have tried a few things with the graph DSL, but have not quite managed to get it working. Would anyone be so kind as to provide me with a snippet to do that or point me in the right direction?</p>
  
  <p>Thanks in advance!</p>