I'm trying to implement a statemachine with redis persitence similar to the "Persisting a statemachine" example from the docs. I have four states SI -> S0 -> S1 -> SF which are conntected by one Event, NEXT.
I use a function feedMachine to send Events to the statemachine, which also checks weather a machine is completed or not:
From a fresh browser window, sending the first event will result in a Got null context, resetting to initial state, clearing extended state and machine id and a new entry in redis, the controller returns state S0 (SI -> S0)
After calling localhost:8080/event?eventName=NEXT two more times, I reach my end state .end(States.SF)
The stateMachine gets deleted from redis via redisTemplate.delete("spring:session:statemachine:" + identifier);
Upon sending the next event, stateMachinePersister will get context null from the db (as no statemachine with this sessionId can be found) and repeat from Step 1
Actual behavior
In Step 4, the statemachine is successfully reset internally using
and also is persisted into redis, but the event is not being processed and the machine will still be in state SI. Debugging it will return isComplete = false, so I dont see any reason why the event would fail now.
I've uploaded a minimal failing example on my private git here which requires a redis db on localhost:6379.
Sidenote: "Resetting" a session by deleting it from the db while its not in a end state (for example because spring session would expires) via
public class MySessionEventListener {
@Autowired
RedisTemplate<String, String> redisTemplate;
@EventListener
public void sessionExpired(SessionExpiredEvent event) {
redisTemplate.delete("spring:session:statemachine:" + event.getSessionId());
}
}
}
Hi,
I'm trying to implement a statemachine with redis persitence similar to the "Persisting a statemachine" example from the docs. I have four states
SI -> S0 -> S1 -> SF
which are conntected by one Event,NEXT
.I use a function
feedMachine
to send Events to the statemachine, which also checks weather a machine is completed or not:My Controller:
Expected behavior
Got null context, resetting to initial state, clearing extended state and machine id
and a new entry in redis, the controller returns stateS0
(SI -> S0)localhost:8080/event?eventName=NEXT
two more times, I reach my end state.end(States.SF)
redisTemplate.delete("spring:session:statemachine:" + identifier);
stateMachinePersister
will get contextnull
from the db (as no statemachine with this sessionId can be found) and repeat from Step 1Actual behavior
In Step 4, the statemachine is successfully reset internally using
and also is persisted into redis, but the event is not being processed and the machine will still be in state
SI
. Debugging it will returnisComplete = false
, so I dont see any reason why the event would fail now.I've uploaded a minimal failing example on my private git here which requires a redis db on
localhost:6379
.Sidenote: "Resetting" a session by deleting it from the db while its not in a end state (for example because spring session would expires) via
works flawlessly.