我正在从akka 2.1迁移到akka 2.2.4,但由于UntypedActorFactory()
已弃用的方法,我在演员之间发送消息时遇到了一些失败。任何人都可以帮我转换这段代码:
public EventWorkerSuperVisor()
{
ActorRef eventWorkerRouter = getContext().actorOf(new Props(
new UntypedActorFactory() {
public UntypedActor create() {
return new EventWorker();
}
}).withRouter(new RandomRouter(10).withSupervisorStrategy(strategy)),
"Event-Worker-Router");
to conform to the creator method...
static class MyActorC implements Creator<MyActor> {
@Override public MyActor create() {
return new MyActor("...");
}
}
答案 0 :(得分:1)
尚未编译但应使用Props.create()
:
ActorRef eventWorkerRouter = getContext().actorOf(
Props.create(EventWorker.class).withRouter(...
或者如果您需要Creator<>
语法,
ActorRef eventWorkerRouter = getContext().actorOf(
Props.create(new MyActorC())).withRouter(...