scala – 在优雅停止后不能总是重用Actor的名字
我为演员研究了Akka的“Graceful Stop”并创建了一个小测试应用来测试它.
应用程序显示http://doc.akka.io/docs/akka/snapshot/scala/actors.html#Graceful_Stop中提到的“Graceful Stop” 偶尔会出现以下异常: Exception in thread "main" akka.actor.InvalidActorNameException: actor name [DummyActor] is not unique! 这是为什么?如何修复应用程序,以便InvalidActorNameExceptions不会偶尔出现? 这是代码: 主要班级…… import akka.actor._ import akka.pattern.gracefulStop import DummyActor.Stop import DummyActor import scala.concurrent.duration._ import scala.concurrent.{Await,Future} object AkkaTest { def main(args: Array[String]) { val actorsystem = ActorSystem("testSystem") 1 to 5 foreach { _ => // Create an actor with name: DummyActor val dummyActor = actorsystem.actorOf(Props[DummyActor],"DummyActor") // Gracefully stop the DummyActor val stopped: Future[Boolean] = gracefulStop(dummyActor,5 seconds,Stop) Await.result(stopped,6 seconds) } val terminated: Future[Terminated] = actorsystem.terminate() Await.result(terminated,10 seconds) System.out.println("Finished successfully. Try again,eventually it will fail. You can also increase the amount of loops.") } } 和演员…… import akka.actor.Actor import DummyActor.Stop object DummyActor { case object Stop } class DummyActor extends Actor { override def receive: Receive = { case Stop => context stop self } } 我有Scala 2.11.7和Java 8和Akka 2.4.0. 解决方法
推荐有很糟糕的格式,所以我会在这里复制它
我只是按照链接,在这里发现红色警报
因此,只有终止接待才能成为主管演员并开始同名 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- Bootstrap 中的 aria-label 和 aria-labelledby
- Font Awesome 字体的以及 图标的使用总结
- macos – 如何从终端打印OSX文本文件的内容?
- angularjs – 使用Angular js处理Select2事件
- angularjs – ng开关不绑定ng模型
- webservice(五) web项目发布webservice
- Angular 2 beta – 选择不起作用(Chrome除外)
- angularjs – Angular ui-select.单独添加选项 –
- angularjs – 量角器不从自动完成搜索地址中选择
- webservice中经常有这样的问题 JAXB 2.0 API is