我正在从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("...");
     }
}

最佳答案

尚未编译,但应该使用Props.create()进行编译:

ActorRef eventWorkerRouter = getContext().actorOf(
    Props.create(EventWorker.class).withRouter(...


或者,如果您需要Creator<>语法,

ActorRef eventWorkerRouter = getContext().actorOf(
    Props.create(new MyActorC())).withRouter(...

07-28 02:05
查看更多