Hi all, I have an Actor which is using Stash and is working through two different Receive behaviours with context.become. Messages are stashed until we're ready to receive them.
I've used context.become(), stash() and unstashAll() several times, so I'm pretty familiar with them, but I'm seeing a bizarre behaviour in this Actor and I was wondering if I'm using it wrong in a subtle way. In the part of the Actor code that is causing the problem, I am doing this: def catchUp: Receive = LoggingReceive { case item: PublishItem => stash() case event: Event => context.become(republishing) unstashAll() } def republishing: Receive = LoggingReceive { case event: PublishItem => downstream ! event case e: Event => // ignore leftover messages from the dying loader } In my test I send a bunch of PublishItem's, then send the Event that changes the behaviour. Then I assert that 'downstream' receives all the backlogged PublishItems. However, what I'm actually seeing are "handled event"s for the PublishItem and Event into the catchUp behaviour. Then I see the test timing out waiting for the PublishItem to appear in downstream and then (the really weird bit) the actor is stopped and AFTER this actor stops, all the PublishItems show up in the dead letters mailbox. Any ideas? As a workaround, I am managing my own stash as a Queue, but this sucks because my stashed messages arrive after other messages that are already queued and that breaks the assumed logic of the whole actor. I'm using akka 2.3.9 on scala 2.11.5 Best regards, Sam -- >>>>>>>>>> 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.