0

I am trying to migrate my app that uses the spring statemachine to use webflux. I was using

private final StateMachineFactory<State, Event> stateMachineFactory;

[...]

StateMachine<State,Event> machine = stateMachineFactory.getStateMachine(stringId);

To get the statemachine at hand (identified by the stringId). But this cannot be done anymore in a reactor thread as getStateMachine is blocking. So how does one go about getting the correct statemachine in a reactive environment?

ouflak
  • 2,458
  • 10
  • 44
  • 49
DiogoV
  • 1
  • spring-statemachine supports reactive access: https://spring.io/blog/2019/08/08/spring-statemachine-goes-reactive-with-3-0-0-m1 – lkatiforis Nov 28 '21 at 07:41
  • Thanks for your response. I have looked at the recipes and samples of the last ssm version (incl reactive examples). From that, however, it is not clear to me how to migrate the use of stateMachineFactory.getStateMachine() to a reactive environment. – DiogoV Nov 28 '21 at 09:54

1 Answers1

0

I could be wrong, but I assume you may need to rehydrate a state machine using a singleton. I haven't migrated to the reactor version yet, so I'm not sure.. Take a look at this related thread over SO Restore machine from context