我有以下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();
}
}
}
我像这样初始化演员
final Props props = Props.create(ActorOnFsm.class); 最终的ActorRef underTest = system.actorOf(道具);
这会出错“unknown actor creator [ActorOnFsm]
在线
final Props props = Props.create(ActorOnFsm.class);
这是初始化这个演员的正确方法吗?
我也尝试更改类以扩展AbstractLogging但结果相同
我也试过创建一个空的构造函数,但结果相同
尝试在道具中发送状态和数据但仍然得到相同的错误
final Props props = Props.create(DeployerOnFsm.class, state, data);
答案 0 :(得分:1)
您应该传递给Props
工厂的课程是ActorFSM
,该课程在ActorOnFsm
内定义:
final Props props = Props.create(ActorOnFsm.ActorFSM.class);
但是,将内部类传递给Props
工厂可能会出现问题。将ActorFSM
作为顶级课程更为常规,在这种情况下,对Props
的调用将更改为:
final Props props = Props.create(ActorFSM.class);
此外,您似乎在其中一个状态转换中出现了拼写错误:
when(FirstState,
matchEvent(soemErrorMessage.class,
// ^
据推测,您打算写SomeErrorMessage.class
而不是soemErrorMessage.class
。