【问题标题】:Spring Statemachine reset state not trigger entry actionSpring Statemachine 重置状态不触发进入动作
【发布时间】:2017-02-17 01:20:27
【问题描述】:

配置代码

states .withStates() .initial(OrderState.Create) .state(OrderState.Create, startAction) .state(OrderState.Payed, paymentAction) .states(EnumSet.allOf(OrderState.class));

运行代码

stateMachine .getStateMachineAccessor() .doWithAllRegions(access -> { access.resetStateMachine(new DefaultStateMachineContext<> (OrderState.Payed, null, null, null, null)); }); stateMachine.start();

paymentAction 启动时不触发, 如何触发

【问题讨论】:

    标签: spring-statemachine


    【解决方案1】:

    好吧,你的代码永远不会进入状态Payed,它会运行paymentAction。它只会进入初始状态Create。以为您没有显示任何转换配置,所以只有在 CreatePayed 之间存在匿名转换时它才会进入该状态。

    【讨论】:

    • 我有一个类似的设置,有 3 个状态和 2 个转换。如上所示,我想以非初始状态(此处为已付款)启动状态机。但是状态机仍然以初始状态开始。是否可以以在我的情况下来自数据库的特定状态启动机器?
    猜你喜欢
    • 1970-01-01
    • 2023-03-18
    • 1970-01-01
    • 2019-03-31
    • 2016-02-11
    • 1970-01-01
    • 1970-01-01
    • 2016-12-07
    • 1970-01-01
    相关资源
    最近更新 更多