Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring State Machine Access to StateContext in eventNotAccepted Listener

I'm new to Spring State Machine. I have used a StateMachineListener for my state machine. How can i access to StateContext in eventNotAccepted method.

@Override
        public void eventNotAccepted(Message<String> event) {

        }
like image 625
Amir Avatar asked Dec 06 '25 19:12

Amir


1 Answers

You need to use StateMachineListener.stateContext(StateContext<S, E>) and listen all StateContext changes. From there check StateContext.getStage() when it matches Stage.EVENT_NOT_ACCEPTED.

Originally when that listener interface were added we didn't have context and later when people wanted access to it we didn't want to break backward compatibility, thus that new method were added.

like image 91
Janne Valkealahti Avatar answered Dec 08 '25 11:12

Janne Valkealahti



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!