Spring state machine does not accept the same event from multiple users

I have a simple state machine with the following States, Eventsand Transitions.

Status: WIP, SUBMITTED, REJECTED, APPROVED

Developments: SUBMIT, APPROVE, REJECT

Transitions:

@Override
public void configure(StateMachineTransitionConfigurer<States,Events> transitions) 
                          throws Exception {
    transitions
        .withExternal()
            .source(States.WIP)
            .target(States.SUBMIT)
            .event(Events.SUBMIT)
            .and()
        .withExternal()
            .source(States.SUBMITTED)
            .target(States.APPROVED)
            .event(Events.APPROVE)
            .and()
        .withExternal()
            .source(States.SUBMITTED)
            .target(States.REJECTED)
            .event(Events.REJECT);;
}
  • WIP to send a SUBMIT message
  • PROVIDED APPROVED FOR APPROVE EVENTS
  • SEND REFUSED for REJECT event

I set WIPas initial state as below:

@Override
public void configure(StateMachineStateConfigurer<States, Events> states) 
            throws Exception {
    states
    .withStates()
        .initial(States.WORK_IN_PROGRESS)
        .states(EnumSet.allOf(States.class));
}

Several users will interact with this state machine. When the same event occurs several times for a combination of the initial and target states, only the first event is received by the state machine, subsequent events are not accepted.

Is this acceptable behavior on the destination machine? If so, is there an additional setting I need to add?

+4

Source: https://habr.com/ru/post/1612550/


All Articles