Open akki1306 opened 2 months ago
First of all, let me tell you that I have no affiliation with Spring State Machine or Development, so please took what I write as a certain grain of salt...
Spring State Machine is great for many use cases but I am not sure it fits your use case, as much as I know Spring State Machine has no concept of unit of work, so several Spring State Machines would coordinate for fulfilment of your scenario, so it will pick and continue the work of another instance if that other instance, in your case k8s pod, terminated...
That level of cluster coordination are provided from other Frameworks like
I explained in one of my Blogs how the Cluster Sharding and State Machine works for Pekko
Cluster Sharding with State Machine
may be this solutions fits better to your requirement, I hope this helps..
I want to run a spring state machine in an AKS cluster with multiple pods running the same application instance. The state machine is long-running and might take over 12 hours to complete. State machine configuration looks like the below with internal state transition every 15 minutes and triggers state change if required conditions are met in the internal state action.
I am using state machine service along with JPA persister.
How do I ensure that the long-running state machine starts running on another pod if any one of the pod crashes or restarts ?
transitions .withExternal() .source(S1).target(S2).event(S1_to_S2).and() .withInternal().timer(Duration.ofMinutes(15)).action(a -> checkAndTriggerEvent());