scala – 运行AKKA远程演员时遇到“Dead Letters遇到”错误
发布时间:2020-12-16 09:28:50 所属栏目:安全 来源:网络整理
导读:我试图在我的localhost上使用AKKA运行远程actor,但每次我都会收到此错误.它说遇到死信.我在互联网上搜索,发现当演员在线程停止后收到消息时会出现此错误.所以我正在寻找一种让演员在远程机器上保持活力的方法.我正在使用akka演员而不是scala演员. [INFO] [09
我试图在我的localhost上使用AKKA运行远程actor,但每次我都会收到此错误.它说遇到死信.我在互联网上搜索,发现当演员在线程停止后收到消息时会出现此错误.所以我正在寻找一种让演员在远程机器上保持活力的方法.我正在使用akka演员而不是scala演员.
[INFO] [09/16/2013 18:44:51.426] [run-main] [Remoting] Starting remoting [INFO] [09/16/2013 18:44:51.688] [run-main] [Remoting] Remoting started; listening on addresses :[akka.tcp://actorSystem1@localhost:2209] [INFO] [09/16/2013 18:44:51.759] [actorSystem2-akka.actor.default-dispatcher-5] [akka://actorSystem2/deadLetters] Message [java.lang.String] from Actor[akka://actorSystem2/deadLetters] to Actor[akka://actorSystem2/deadLetters] was not delivered. [1] **dead letters encountered**. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'. 以下是代码. import akka.actor.{Actor,Props,ActorSystem} import com.typesafe.config.ConfigFactory import akka.remote._ object MyApp extends App { val actorSystem1 = ActorSystem("actorSystem1",ConfigFactory.parseString(""" akka { actor { provider = "akka.remote.RemoteActorRefProvider" } remote { transport = ["akka.remote.netty.tcp"] netty.tcp { hostname = "localhost" port = 2209 } } } """)) val actorSystem2 = ActorSystem("actorSystem2") actorSystem1.actorOf(Props(new Actor { def receive = { case x: String => Thread.sleep(1000) println("RECEIVED MESSAGE: " + x) } }),"simplisticActor") val remoteActor = actorSystem2.actorFor("akka://actorSystem1@localhost:2209/user/simplisticActor") remoteActor ! "TEST 1" remoteActor ! "TEST 2" Thread.sleep(1000) actorSystem1.shutdown() actorSystem2.shutdown() } 提前致谢. 解决方法
我想我看到你的代码可能会导致一些问题.首先,如果您的目的是将一个远程系统上的actor从actorSystem2查找到actorSystem1,那么您仍然需要为actorSystem1设置远程属性,更具体地说,您需要确保它使用RemoteActorRefProvider.如果不这样做,系统2将无法在系统1中查找远程actor.一旦进行了此更改,我还将更改您的远程actor查找:
val remoteActor = actorSystem2.actorFor("akka://actorSystem1@localhost:2209/user/simplisticActor") 至: val remoteActor = actorSystem2.actorSelection("akka.tcp://actorSystem1@localhost:2209/user/simplisticActor") 不推荐使用actorFor方法,而且我认为你没有使用akka协议的.tcp部分来查找远程actor. 进行这些更改,然后查看是否适合您. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |