【发布时间】:2018-08-31 16:51:14
【问题描述】:
我有以下 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();
}
}
}
我这样初始化actor
最终道具 props = Props.create(ActorOnFsm.class); 最终 ActorRef underTest = system.actorOf(props);
这给出了一个错误“unknown actor creator [ActorOnFsm]
就行了
final Props props = Props.create(ActorOnFsm.class);
初始化这个actor的正确方法是什么?
我也尝试更改类以扩展 AbstractLogging 但结果相同
我也尝试创建一个空的构造函数,但结果相同
尝试在 props 中发送状态和数据,但仍然得到相同的错误
final Props props = Props.create(DeployerOnFsm.class, state, data);
【问题讨论】: