0
votes

I have the following FSM

public class ActorOnFsm {
    public static enum State {
    FirstState,
    SecondState,
    ThirdState,
    FourthState
    }

    public static final class ServiceData {

    }


    public class ActorFSM extends AbstractFSM<State, ServiceData> { 
    {
        startWith(FirstState, new ServiceData());
        when(FirstState,
            matchEvent(SomeMessage.class,
                ServiceData.class,
                (powerOn, noData) ->
            goTo(SecondState)
            .replying(SecondState))
            );


        when(SecondState,
            matchEvent(SomeOtherMessage.class,
                ServiceData.class,
                (powerOn, noData) ->
            goTo(ThirdState)
            .replying(ThirdState))
            );

        when(FirstState,
            matchEvent(soemErrorMessage.class,
                ServiceData.class,
                (powerOn, noData) ->
            goTo(FourthState)
            .replying(FourthState))
            );

        initialize();
    }



    }
}

I initialize the actor like this

final Props props = Props.create(ActorOnFsm.class); final ActorRef underTest = system.actorOf(props);

This gives an error " unknown actor creator [ActorOnFsm] on the line

final Props props = Props.create(ActorOnFsm.class);

Wht is the correct way to initialize this actor?

I also tried changing the class to extend AbstractLogging but same result

I also tried creating an empty constructor but same result

Tried sending the state and data in the props but still get the same error

    final Props props = Props.create(DeployerOnFsm.class, state, data);
1

1 Answers

1
votes

The class that you should pass to the Props factory is ActorFSM, which is defined inside ActorOnFsm:

final Props props = Props.create(ActorOnFsm.ActorFSM.class);

However, there may be issues with passing an inner class to the Props factory. It would be more conventional to make ActorFSM a top-level class, in which case the call to Props would change to:

final Props props = Props.create(ActorFSM.class);

Also, you appear to have a typo in one of your state transitions:

when(FirstState,
    matchEvent(soemErrorMessage.class,
              // ^

Presumably, you intended to write SomeErrorMessage.class instead of soemErrorMessage.class.