I tried to do hierarchical fsm using just nested akka fsms. It doesn't work (they never said it did) because of the problem of passing messages through to children asynchronously - you may have 2 messages come through in rapid succession and you have to manually queue the second one while you're firing up the new state. Then I considered "why should akka fsm support hierarchies via multiple actors". Surely the essence of the fsm is that it is only doing one thing at a time because it's only in one state at a time. You can't transition to a new state until you've finished with the old one. Actors are inherently doing different things at the same time - so other than the fact that we have a single tier fsm in Akka why start there as a means of abstraction of the problem? My solution was to create my own hierarchical fsm using immutable structures - essentially a stack (child changes, the stack changes, percolating upwards). Once I'd made the effort I found it suited me very nicely. All I need is to wrap it all in a single actor that processes incoming messages and passes them down.
I think my conclusion is that just because akka does a single tier fsm nicely it doesn't mean that having multiple actors is a good model for a complex fsm. And if it's not done with multiple actors why do it with the akka fsm at all? With a bit of effort you could produce a dsl that was pretty similar to Akka's in terms of those nice gotos and transitions but in a single thread. The fsm is then only doing one thing at a time and the wrapper actor is handling the queuing for you. I didn't go as far as a dsl because I don't need to -my total model has 10 sub-fsms (including sub-sub-fsms) and probably no more than 30 different states so it wasn't worth too much api writing. Tim On Saturday, January 4, 2014 12:27:35 AM UTC, Nicholas Ustinov wrote: > > Hello! > > I found some useful discussions in this list about hierarchical FSMs, I > mean > > https://groups.google.com/forum/?fromgroups#!searchin/akka-user/state$20machine/akka-user/Lqezg-y215g/TdiyWEklW7gJ > > https://groups.google.com/forum/?fromgroups#!searchin/akka-user/state$20machine/akka-user/Sfl3Xcul86I/8HW1CZJoHtcJ > > https://groups.google.com/forum/?fromgroups#!searchin/akka-user/first-day/akka-user/eX_3rZ-cNNw/kV9YNzsSnkUJ > > and some others. > > So I understand that akka's FSM realization doesn't have support of > hierarchical and parallel FSMs. But it's very interesting, if you have some > plans or thoughts for this? > Especially for orthogonal states of FSMs. > I think, for toy things or very simple abstractions current realization > will be good enough, but for real-world domain modeling you will need > support of smth like things, described in SCXML specification, i mean, > support for full-blown Harel state machines. > I ask because I need to implement some domain abstractions in this way and > i'm looking for the cheapest way for implementing it. > > Thank you, > Nicholas > -- >>>>>>>>>> Read the docs: http://akka.io/docs/ >>>>>>>>>> Check the FAQ: http://akka.io/faq/ >>>>>>>>>> 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/groups/opt_out.
