0

I'm struggling to persist my state machine following the recipes and examples available. I'm working with the master branch and my state machine uses Hierarchical States, Regions and Orthogonal states. The first example I followed is spring-statemachine-samples/persist but it seems to deal only with basic FSM. The second one I tried is LocalStateMachineInterceptor but id does not seem to be working with Hierarchical States. Also, I can't find any way to persist an history state via a StateMachinePersist.

Is there an example of a complex FSM with persistence anywhere?

Vertexwahn
  • 7,709
  • 6
  • 64
  • 90
  • Hold on, regarding a question about a history state. As I created a #182 for it and started to work on it, I couldn't figure out how to actually use it with a persistence. As history state is a transient and a pseudo state, as it's simply tracking last known state, you can't really reset a machine into that state as its only job is to go immediately into its last known state. So would you mind to elaborate what you meant by persisting a history state? – Janne Valkealahti Mar 06 '16 at 18:41
  • After restoring a FSM if one of the transitions available in the current state has as a target a _HISTORY_ pseudo state, triggering such event should move the FSM to the previous state. This is currently implemented (I think) looking at the information stored into the HistoryPseudoState that get lost on save/restore – Alessandro Di Bella Mar 07 '16 at 06:56
  • Ok, I think there's still some work done here but I just enhanced features around persisting history. You can follow changes in #182. Sorry for my original comment that you're "holding it wrong", you were right :) Thanks! – Janne Valkealahti Mar 12 '16 at 16:04

1 Answers1

0

I have to be honest that persistence is one relatively unknown topic for samples and docs when things gets more complicated. It is something I'm currently working on to make it easier because as a user you should not care as there should be a relatively clean API's to do it. So stay tuned for those.

Having said that, before we get code more clear on this;

StateMachinePersist leads to StateMachineContext and there is some code in tests, namely StateMachineResetTests which shows some ways to do these things. There was also a question gh127 where I wrote something about internals of resetting a machine which is what a persistence does.

History state, yes that's my bad, for some reason it has slipped from my radar. Thanks for pointing it out! Created an issue for it gh182.

Janne Valkealahti
  • 2,552
  • 1
  • 14
  • 12