I have properly working graph that has flow with loop. Items go through as 
expected and everything is working. But unfortunately with bounded source 
graph never ends. Ever. How can I fix it ?


Here is schema of my flow.


[image: enter image description here] <http://i.stack.imgur.com/xAByR.jpg>


Here is simplified version of the flow with the same topology.


val badFlow = Flow.fromGraph(GraphDSL.create() { implicit builder =>
  import GraphDSL.Implicits._

  val mergeEntrance = builder.add(MergePreferred[Int](1))
  val mergePreExit = builder.add(Merge[Int](2))
  val bcast1 = builder.add(Broadcast[Int](2))
  val bcast2 = builder.add(Broadcast[Int](2))

  mergeEntrance.out ~> bcast1.in

  bcast1.out(0) ~> Flow[Int].filterNot(_ == 1) ~> mergePreExit.in(0)

  bcast2.in <~ Flow[Int].collect {
    case v if v == 1 =>
      -1
  } <~ bcast1.out(1)

  mergeEntrance.preferred <~ Flow[Int].filter(_ == 1) <~ bcast2.out(0)

  bcast2.out(1) ~> Flow[Int].filterNot(_ == 1) ~> mergePreExit.in(1)

  FlowShape.of(mergeEntrance.in(0), mergePreExit.out)})
val completionFut = Source(List(0, 1, 2, 3))
  .buffer(4, OverflowStrategy.fail)
  .via(badFlow)
  .mapAsync(1) {
    case v => Future.successful(v * 10)
  }
  .toMat(Sink.foreach(v => println(s">>> $v")))(Keep.right).run()
for (result <- completionFut)
  println("Stream is over!")


I tried to stick ".buffer()" everywhere as suggested in "Graph cycles, 
liveness and deadlocks" but it didn't help :(


SO question: 
http://stackoverflow.com/questions/38033362/loop-in-flow-makes-stream-never-end

-- 
>>>>>>>>>>      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