使用AKKA Java API启动ActorSystem的正确方法
我正在使用Akka 2.0的Java API,并且有一种令人沮丧的感觉,我没有正确地使用ActorSystem来启动和/或/xor停止TypedActors。当应用程序关闭时,java进程不会终止。调试后,我看到默认调度程序仍有多个正在运行的线程,并且调度程序仍在运行。在下面的例子中,是否有明显的错误使用AKKA Java API启动ActorSystem的正确方法,java,akka,typedactor,Java,Akka,Typedactor,我正在使用Akka 2.0的Java API,并且有一种令人沮丧的感觉,我没有正确地使用ActorSystem来启动和/或/xor停止TypedActors。当应用程序关闭时,java进程不会终止。调试后,我看到默认调度程序仍有多个正在运行的线程,并且调度程序仍在运行。在下面的例子中,是否有明显的错误 Config akkaConf = ConfigFactory.load(); ActorSystem actorSystem = ActorSystem.create("myApp", akka
Config akkaConf = ConfigFactory.load();
ActorSystem actorSystem = ActorSystem.create("myApp", akkaConf);
TypedProps<Actor1Impl> actor1TypedProps = new TypedProps<Actor1Impl>(Actor1Interface.class, new Creator<Actor1Impl>(
public Actor1Impl create() {
return new Actor1Impl(nonDefault, constructor, scalaIsSo, muchMoreElegant);
}
);
Actor1Interface a1 = TypedActor.get(actorSystem).typedActorOf(actor1TypedProps, "anA1Actor");
我正在做的任何事情都是明显错误的,这会阻止java进程终止吗?具体地说,任何会导致调度程序和默认调度程序关闭的操作?将ActorSystem配置为使用守护程序线程,然后应用程序将立即退出。@landon9720全部内容如下:
public Actor2Impl(Actor1Interface a1) {
a1.registerCallback(TypedActor.<Actor2Interface>self());
}
TypedActor.get(actorSystem).stop(a1);
TypedActor.get(actorSystem).stop(a2);
...
TypedActor.get(actorSystem).stop(aN);
actorSystem.shutdown();