Partition allows you to look at a message and decide which of its outlets
to pass the element to, this way you can design the logic of each sub
stream independently. Something like this:

val flow: Flow[Int, Int, NotUsed] = Flow.fromGraph(GraphDSL.create() {
implicit builder =>
    import GraphDSL.Implicits._

    val partition = builder.add(Partition[Int](2, _ % 2))
    val merge = builder.add(Merge[Int](2))

    val processEven = builder.add(Flow.fromFunction((n: Int)  => n + 100))
    val processOdd = builder.add(Flow.fromFunction((n: Int) => n - 1))

    partition.out(0) ~> processEven ~> merge.in(0)
    partition.out(1) ~> processOdd ~> merge.in(1)

    FlowShape(partition.in, merge.out)
  })


-- 
Johan
Akka Team

On Tue, Mar 21, 2017 at 1:18 PM, Vishal John <[email protected]> wrote:

>
> Hello all,
>
>
> I have defined my application flow like this,
>
> *val flow = Flow[StringConsumerRecord].*
> *  map(tup => new Ticket(tup.value.toLong)).*
> *  mapConcat(applyBusinessLogic(_)).*
> *  groupBy(4, _._1).*
> *  groupedWithin(100, 5.second).*
> *  mergeSubstreams.*
> *  throttle(1, 1.second, 1, ThrottleMode.shaping)*
>
>
> Basically I don't want to apply `*groupedWithin(100, 5.second)*` for all
> the sub flows.
>
> Based on the type of the grouped data, for one sub stream I want to do 
> *groupedWithin(10,
> 10.second) *and for another *groupedWithin(1000, 1.second) etc... *and
> finally merge all. Basically I am trying to do some sort to pattern
> matching on the sub-flows and take different actions.
>
> Can someone give any pointers on how to achieve this.
>
>
> -thanks
> Vishal
>
> --
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/
> current/additional/faq.html
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to