【发布时间】:2019-03-07 15:29:04
【问题描述】:
我试图了解,在状态转换期间操作引发的异常是如何发生的。我已经配置了这个简单的状态机:
transitions
.withExternal()
.source(State.A1)
.target(State.A2)
.event(Event.E1)
.action(executeAnActionThrowingAnException())
在我的服务类中,我注入了我的状态机并发送此事件 E1:
@Service
public class MyService() {
@Autowired
private StateMachine<State, Event> stateMachine;
public void executeMyLogic() {
stateMachine.start()
stateMachine.sendEvent(Event.E1);
// how to get thrown exception here
}
}
在我的服务中,我只想知道,我的状态机是否以及为什么无法到达 State.A2。因为 Spring 状态机获取了抛出的异常,所以在发送事件后我无法得到任何响应。但是状态机没有任何错误,这意味着
stateMachine.hasStateMachineError()
将返回 false。那么,我怎样才能在我的服务中获取信息,指出出了什么问题,更重要的是什么?
感谢您的帮助。
最好的问候
【问题讨论】:
标签: java spring spring-statemachine