I am setting up spring state-machine transactions, i want to launch Event2 on completion of Event1
These are the states i have
States -> "INITIAL", "SECOND", "THIRD"
I have configured the transactions to send SECOND_EVENT from action of FIRST_EVENT as shown below
transitions.withExternal()
.source("INITIAL")
.target("SECOND")
.event("FIRST_EVENT")
.action(new Action<String, String>() {
@Override
public void execute(StateContext<String, String> context) {
System.out.println("FIRST_ACTION_EXECUTED");
context.getStateMachine().sendEvent("SECOND_EVENT");
}
})
.and()
.withExternal()
.source("SECOND")
.target("THIRD")
.event("SECOND_EVENT")
.action(new Action<String, String>() {
@Override
public void execute(StateContext<String, String> context) {
System.out.println("TEST SUCCESS");
}
});
Here i get evenNotAccepted exception, and i know the reason is that the statemachine.getState() is INITIAL, and it cant change the state from INITIAL to THIRD directly.
So my question is, Is there anyway that i can configure my statemachine to automatically trigger second event on completion of first event