spring-projects / spring-statemachine

Spring Statemachine is a framework for application developers to use state machine concepts with Spring.
1.57k stars 616 forks source link

JpaPersistingStateMachineInterceptor does not persist deferred events #550

Open rjayasinghe opened 6 years ago

rjayasinghe commented 6 years ago

I have an application that uses a small state machine with deferred events. The state machine is configured with a JpaPersistingStateMachineInterceptor to automatically persist state changes. Handling deferred events works fine unless I do not restart the JVM while events are deferred (kept in the deferred list). When the JVM is restarted the deferred events are lost.

I searched a bit in the code and realised that the deferred event list is not part of the StateMachineContext (which is persisted by the JPAPersistingStateMachineInterceptor). It is a member of the DefaultStateMachineExecutor which is not persisted as far as I can see.

Is this intended behaviour? Have I missed anything?

jvalkeal commented 6 years ago

This is just a missing feature. Persist is also missing normal event which would be nice to have as if event takes you through a chain of anonymous transitions, that event is available in a state context. If you restore to state where it goes to next state, event is not available anymore. These two things goes hand on hand. It's has been on my todo list for a while and I actually have a use case somewhere else where this is also needed.

Hopefully we get this done in near future.

rjayasinghe commented 6 years ago

Just in case you have a rough idea how this could be implemented and think it could be done by a newbie I'd volunteer to contribute. 🐒

cece346 commented 3 years ago

Hi, have there been any updates to this issue? Or are there any known workarounds? Thanks!

We are encountering this very issue in our team's usage of the Spring statemachine

wlfbck commented 2 months ago

same question as @cece346 from 3 years ago :)