到目前为止,我在状态机方面取得了很好的进展。我最近的问题出现在我想要使用fork时(我正在使用UML)。叉子不能正常工作,我认为这是因为它的持久性。我将我的机器持久化在redis中。请参阅下图。

这是我的顶层机器,其中Manage-commands是一个子机器引用,顶层区域是原样。
现在假设我在redis中持久化了一些状态,来自下面的区域,下一个在线事件出现,然后机器不接受这个事件,显然是因为我已经要求机器用给定的键从redis恢复状态。但是我希望这两个区域都是持久化的,以便根据事件选择其中一个。有什么方法可以做到这一点吗?
下面是我如何持久化和恢复
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;
}发布于 2017-03-21 19:27:49
这有点奇怪,因为我发现了一些关于持久性的其他问题,我在1.2.x中修复了这些问题。可能与您的问题无关,但我希望您会看到类似的错误。不管怎样,你可以检查一下RedisPersistTests.java,看看你正在做的事情有没有什么不同。我还没有尝试子机引用,但从持久性的角度来看,我不应该做任何改变。
https://stackoverflow.com/questions/42779463
复制相似问题