Hi Srinivas, You can consider using Persistent FSM <http://doc.akka.io/docs/akka/2.4-M2/scala/persistence.html?_ga=1.127649677.1441866889.1394995817#Persistent_FSM>, this way the state of the FSM can be recovered upon restart. This will let you take down the inactive actors - they can later be started again on demand, in the state they were in before the stop.
Warning: Persistent FSM is marked as an experimental feature, it was just added to Akka 2.4-M2. In case you do try it, it would be interesting to get your feedback. Thanks, Leonid On Wednesday, July 1, 2015 at 8:04:43 AM UTC+3, Srinivas wrote: > > Hello, > > I am trying to build order fulfilment component with AKKA FSM. I have few > basic doubts on how the state is been stored and taken further upon event > from user. > > *Consider states* > > ORDER_CLEAN, ORDER_INIT, ORDER_PAYMENT_WAITING, ORDER_PAYMENT_SUCCESS, > ORDER_DELIVERY, ORDER_COMPLETE > > *Events as* > > EV_CART_CHECKOUT, EV_PROCEED_PAYMENT, EV_PAYMENT_SUCCESSFUL, > EV_ITEMS_PACKED, EV_DELIVERED > > *State changes as* > > (EV_CART_CHECKOUT, ORDER_CLEAN) -> ORDER_INIT(EV_PROCEED_PAYMENT, ORDER_INIT) > -> ORDER_PAYMENT_WAITING(EV_PAYMENT_SUCCESSFUL, ORDER_PAYMENT_WAITING) -> > ORDER_PAYMENT_SUCCESS(EV_ITEMS_PACKED, ORDER_PAYMENT_SUCCESS) -> > ORDER_DELIVERY (EV_DELIVERED, ORDER_DELIVERY) -> ORDER_COMPLETE > > *Questions* > > 1. > > When we create FSM actors starting at ORDER_CLEAN with event > EV_CART_CHECKOUT, would this actor is alive till we bring it to > ORDER_COMPLETE(assuming we stop actor at this state) state? > 2. > > If yes to above point, in that case as we store order status on > database how do we trigger new event on that actor? Is that do we need to > maintain order_id to actor mapping and trigger event? What if there > are *10K* unique orders are currently being processed then we maintain > mapping for all *10K* actors is it? If so what is best data structure > for maintaining these mappings for larger number of orders? > 3. > > In continuation to 2nd point, what if actors go down how to bring back > actors to same state? Is supervisor actor only way to solve this? Or do we > need to check actor status and then send event? > 4. > > At any point of state, user might not trigger next event may be for > days, then is it good to keep actor live for such longer time or is it > good > to create new actor with updated state? > > What are the better approaches to address these problems with akka FSM > -- >>>>>>>>>> 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.
