Reputation: 177
Suppose i have three state A,B,C and state machine is initialisation occur if user fire some api call . if transition is going to happen from state A -> B -> C then at state B wanted to send response to user and then user will cal same api by appending some payload and then it has to go state C.
Is that possible to achieve this business use case using spring state machine. If possible then how we can do that. If not possible from spring state machine which framework i can use to achieve this use case
Upvotes: 0
Views: 72
Reputation: 120
Yes, you can achieve this use case,
I but you need to persist the information somewhere, So that you know what information to feed and in which state, you should reset the state machine.
There are advanced controls in state machine where you can reset the state machine to a particular state. I'm assuming that you are using a state machine factory to get a state machine.
stateMachine.getStateMachineAccessor().doWithAllRegions(access -> access
.resetStateMachine(new DefaultStateMachineContext<>(state, null, null,null)));
With the above code, you will get a state machine that already is in the required state then you can pass context store with the required information.
Upvotes: 0