Hi, Yes, exactly that happens, great that you figured out. I recommend looking at our blog series about custom stages to understand better how to design stages. While this post is about parsing XML, it actually has quite a bit of information on how to attack custom stage design (which is independent of XML): http://blog.akka.io/integrations/2016/09/16/custom-flows-parsing-xml-part-1
-Endre On Thu, Oct 27, 2016 at 11:23 PM, Vay Ngo <[email protected]> wrote: > Figured it out. In my custom Bidi, I needed to override the default > onUpstreamFinish() and onDownStreamFinish() methods on the in/out handlers, > since by default they complete the entire stage (i.e. the whole Bidi). > This meant that the completion of the requestIn port (invoked after the > single message from the source was received), the stage was completed > before the message could flow through the response flow. The fixed code is > pasted below: > > override def createLogic(inheritedAttributes: Attributes): GraphStageLogic = > new GraphStageLogic(shape) { > setHandler(requestIn, new InHandler { > override def onPush(): Unit = { > push(requestOut, grab(requestIn)) > } > override def onUpstreamFinish() = complete(requestOut) > }) > > setHandler(requestOut, new OutHandler { > override def onPull(): Unit = { > pull(requestIn) > } > override def onDownstreamFinish() = cancel(requestIn) > }) > > setHandler(responseIn, new InHandler { > override def onPush(): Unit = { > val msg = grab(responseIn) > push(responseOut, msg) > } > override def onUpstreamFinish() = completeStage() > }) > > setHandler(responseOut, new OutHandler { > override def onPull(): Unit = { > pull(responseIn) > } > override def onDownstreamFinish() = cancel(responseIn) > }) > } > > > > -- > >>>>>>>>>> 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. > -- Akka Team Lightbend <http://www.lightbend.com/> - Reactive apps on the JVM Twitter: @akkateam -- >>>>>>>>>> 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.
