spring-projects / spring-statemachine

Spring Statemachine is a framework for application developers to use state machine concepts with Spring.
1.56k stars 613 forks source link

Is it possible to have multiple statemachines using @EnableStateMachineFactory #822

Open renjithy85 opened 4 years ago

renjithy85 commented 4 years ago

Hi Team,

I have an use case of having one statemachine for trip and another one for order. Statemachine was working fine with trip but when introduced new statemachine for Order Code compilation got failed.

here is my state machine configuration

@Configuration @EnableStateMachineFactory

public class TripStateMachineConfiguration extends EnumStateMachineConfigurerAdapter<TripState, TripEvent> {

@Configuration @EnableStateMachineFactory public class OrderStateMachineConfiguration extends EnumStateMachineConfigurerAdapter<OrderState, OrderEvent> {

Here is I am trying to autowire it

@Autowired private StateMachineFactory<TripState, TripEvent> stateMachineFactory;

@Autowired private StateMachineFactory<OrderState, OrderEvent> stateMachineFactory;

I am getting below error

Field stateMachineFactory in com.ril.newcommerce.supplychain.tms.statemachine.OrderStateMachineHandler required a bean of type 'org.springframework.statemachine.config.StateMachineFactory' that could not be found.

I can see that TripStateMachineConfiguration gets executed when code complies.

Daanielvb commented 2 years ago

Have you figured out a way of inject multiple configuration yet?