spring-projects / spring-statemachine

Spring Statemachine is a framework for application developers to use state machine concepts with Spring.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Transition with the same event in multiple regions

Balint-Ivanics-KUKA opened this issue · comments

Hi,

Multiple regions of the same state machine using the same event for transition don't react as I would expect based on the docs.
"Whether you send one event or multiple events, result is always a sequence of results. This is so because in a presence multiple reqions, results will come back from multiple machines in those regions. This is shown with method sendEventCollect which gives a list of results." To me this suggested that multiple regions can accept the event but it looks like that is not the case.

If I have the following state machine:

    public void configure(StateMachineStateConfigurer<MyStateMachineState, MyStateMachineEvent> states)
            throws Exception
    {
        states
                .withStates()
                .initial(BasicState.ROOT)
                .and()
                .withStates()
                .parent(BasicState.ROOT)
                .region("region1")
                .initial(BasicState.CHILD11)
                .state(BasicState.CHILD12)
                .and()
                .withStates()
                .parent(BasicState.ROOT)
                .region("region2")
                .initial(BasicState.CHILD21)
                .state(BasicState.CHILD22);
    }

    public void configure(StateMachineTransitionConfigurer<MyStateMachineState, MyStateMachineEvent> transitions)
            throws Exception
    {
        transitions
                .withExternal().source(BasicState.CHILD11).target(BasicState.CHILD12).event(BasicEvent.EVENT)
                .and()
                .withExternal().source(BasicState.CHILD21).target(BasicState.CHILD22).event(BasicEvent.EVENT);
    }

then if I send a BasicEvent.EVENT only one of the regions will transition. I would have expected both to transition.

Is this the intended behavior?

Thanks