【问题标题】:Spring Statemachine ForksSpring 状态机分叉
【发布时间】:2017-03-14 06:53:06
【问题描述】:

到目前为止,我在状态机方面取得了不错的进展。当我想使用 fork 时,我最近的问题出现了(我正在使用 UML)。叉子没有按预期工作,我认为这是因为持久性。我将我的机器保存在redis中。参考下图。

这是我的顶级机器,其中 Manage-commands 是子机器引用,而顶部区域是原样。

现在说我在redis中坚持了一些状态,从下面的区域,然后一个ONLINE事件来了,然后机器不接受这个事件,很明显是因为我已经要求机器用给定的键从redis恢复状态. bur 我希望两个区域都被持久化,以便根据事件选择其中一个。 有什么方法可以实现吗?

以下是我如何坚持和恢复

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;
}

【问题讨论】:

  • 您介意多讲讲您是如何坚持不懈的吗?即您基于哪个示例代码以及您正在使用哪些类?
  • 我已经用代码编辑了我的问题,供您参考
  • 嗯,我还看到带有这些深度状态的 redis 有一些奇怪的地方。莱米戳得更深了。
  • 好的,我会很高兴收到你的来信

标签: spring state-machine spring-statemachine


【解决方案1】:

这有点奇怪,因为我在1.2.x 中发现了一些其他持久性问题。可能与您的问题无关,但我希望您会看到类似的错误。无论如何,您可以检查RedisPersistTests.java,看看您正在做的事情是否有所不同。我还没有尝试子机引用,但从持久性的角度来看,我不应该有任何区别。

【讨论】:

  • 嗨,有什么方法可以使用 UML 将参数传递给操作
  • 你能说得更具体一点吗?你想完成什么?
猜你喜欢
  • 1970-01-01
  • 2015-04-21
  • 2023-03-27
  • 1970-01-01
  • 1970-01-01
  • 2016-12-07
  • 2016-07-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多