弹簧状态机叉 [英] Spring Statemachine Forks
问题描述
到目前为止,我在状态机方面取得了不错的进步.我最近的问题出现在我想使用fork的时候(我正在使用UML).叉子没有按预期工作,我认为这是因为它的持久性.我将机器保留在Redis中.请参考下图.
I have made good progress with the state machines upto now. My most recent problem arised when I wanted to use a fork, (I'm using UML). The fork didn't work as it is supossed to and I think its because of the persistance. I persist my machine in redis. refer below image.
这是我的顶级计算机,其中管理命令"是子计算机"参考,并且顶部区域保持原样.
This is my top level machine where Manage-commands is a Sub machine Reference And the top region is as it is.
现在说我在以下区域中保持Redis的某些状态,然后出现一个ONLINE事件,则机器不接受该事件,显然是因为我已要求机器使用给定的密钥从Redis还原状态. bur我希望两个区域都保留下来,以便根据事件选择其中一个. 有什么办法可以做到这一点?
Now say I persisted some state in redis, from the below region, and next an ONLINE event comes, then the machine does not accept the event, clearly because I have asked the machine to restore the state from redis with a given key. bur I want both the regions to be persisted so that either one is selected according to the event. Is there any way to achieve this?
以下是我坚持还原n的方式
Below is how I persist n restore
private void feedMachine(StateMachine<String, String> stateMachine, String user, GenericMessage<String> event)
throws Exception {
stateMachine.sendEvent(event);
System.out.println("persist machine --- > state :" + stateMachine.getState().toString());
redisStateMachinePersister.persist(stateMachine, "testprefixSw:" + user);
}
private StateMachine<String, String> resetStateMachineFromStore(StateMachine<String, String> stateMachine,
String user) throws Exception {
StateMachine<String, String> machine = redisStateMachinePersister.restore(stateMachine, "testprefixSw:" + user);
System.out.println("restore machine --- > state :" + machine.getState().toString());
return machine;
}
推荐答案
这有点怪异,因为我发现了其他一些与持久性相关的问题,这些问题已在1.2.x
中修复.可能与您的问题无关,但我希望您会看到类似的错误.无论如何你可以检查
It's a bit weird as I found some other issues with persistence which I fixed in 1.2.x
. Probably not related to your issues but I would have expected you to see similar errors. Anyway could you check RedisPersistTests.java and see if there's something different what you're doing. I didn't yet try sub-machine refs but I should not make any difference from persistence point of view.
这篇关于弹簧状态机叉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!