You've got your demand condition as 'DemandFromAny', when I think it should 
be 'DemandFromAll'. I'm not exactly sure why that would explain your exact 
behaviour, but it should help.

If you consciously don't want to wait for demand from both, you could e.g. 
have 2 states which are randomly chosen between.

On Friday, 19 June 2015 22:55:37 UTC+1, Eric Nelson wrote:
>
> Hi all. I'm using Akka Streams 1.0-RC3, and am getting some weird behavior 
> with a custom FlexiRoute. I'll post the code below, but the behavior I'm 
> seeing is that when this FlowGraph is run, I only see one or two outputs in 
> the log, and then nothing more. I can't figure out why the stream isn't 
> completing with all 20 inputs as it should. Any help is greatly appreciated.
>
> class BillingRouteShape[A](_init: Init[A] = Name[A]("Router")) extends 
> FanOutShape[A](_init) {
>   val outA = newOutlet[A]("outA")
>   val outB = newOutlet[A]("outB")
>   protected override def construct(i: Init[A]) = new BillingRouteShape(i)
> }
>
> class BillingRoute[A] extends FlexiRoute[A, BillingRouteShape[A]](
>   new BillingRouteShape, OperationAttributes.name("Router")) {
>
>   val rand = new java.util.Random()
>
>   override def createRouteLogic(p: PortT) = new RouteLogic[A] {
>     override def initialState =
>     State(DemandFromAny(p.outA, p.outB)) {
>       (ctx, _, element) =>
>         val nxt = rand.nextInt(100)
>         if((nxt % 2) == 0)
>           ctx.emit(p.outA)(element)
>         else
>           ctx.emit(p.outB)(element)
>
>       SameState
>     }
>   }
> }
>
> FlowGraph.closed() { implicit b =>
>   import FlowGraph.Implicits._
>
>   val src = Source(1 to 20)
>
>   val route = b.add(new BillingRoute[Int])
>
>   src ~> route.in
>   route.outA ~> Sink.foreach((x: Int) => println(s"RouteA: $x"))
>   route.outB ~> Sink.foreach((x: Int) => println(s"RouteB: $x"))
> }.run()
>
> Each run I'll see a different number of print statements, sometimes 1, 
> sometimes 3 or 4. But never do I get all 20. It does seem to be randomly 
> routing to `outA` and `outB`, but the stream just isn't completing. I'm 
> banging my head against a wall at this point. Any ideas? 
>
> --Eric
>
>
>

-- 
>>>>>>>>>>      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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to