I am hoping for some guidance on how to handle message envelope processing 
outside of my concrete PersistentActors. In my system I am wrapping 
commands in an envelope. I wrote a stackable trait to abstract the envelope 
handling away from my business logic. 

I am following the pattern as described by Ooyala 
<http://www.slideshare.net/EvanChan2/akka-inproductionpnw-scala2013> (slides 
15+):

trait PersistentActorStack extends PersistentActor { outer: ActorLogging =>
  def wrappedReceiveCommand: Receive
  def wrappedReceiveRecover: Receive

  override def receiveCommand: Receive = {
    case c if wrappedReceiveCommand.isDefinedAt( c ) => 
wrappedReceiveCommand( c )
    case c => unhandled( c )
  }

  override def receiveRecover: Receive = {
    case e if wrappedReceiveRecover.isDefinedAt( e ) => 
wrappedReceiveRecover( e )
    case e => unhandled( e )
  }
}

My concrete actor ultimately extends this trait and implements a state 
machine via become with something like the following states:

val stateA: Receive = { ... }
val stateB: Receive = { ... }
val stateC: Receive = { ... }

I start off with startA:

override def wrappedReceiveCommand: Receive = stateA

The actor behaves and processed commands as expected until I become another 
state; e.g., stateB. Once I call context.become( stateB ), the state isn't 
recognized and I see that wrappedReceiveCommand is called and returning 
stateA. (I used logging to see this.) This doesn't surprise me, however the 
examples I've seen in tutorials and tests utilize context.become(). I am 
struggling to find non-trivial example using become with a stackable trait 
pattern. Do they fit together? Is there a suggested alternative.

Thanks so much for your advice!

Damon

-- 
>>>>>>>>>>      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 http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to