运行AKKA远程演员时出现"Dead Letters遇到"错误

nit*_*h99 7 remoting scala actor akka

我试图在我的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'.   
Run Code Online (Sandbox Code Playgroud)

以下是代码.

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()
 }
Run Code Online (Sandbox Code Playgroud)

提前致谢.

cmb*_*ter 6

我想我看到你的代码可能会导致一些问题.首先,如果你的目的是要查找一个远程系统上的演员从actorSystem2actorSystem1,那么你仍然需要设置远程处理性能actorSystem1,最具体,你需要确保它的使用RemoteActorRefProvider.如果不这样做,系统2将无法在系统1中查找远程actor.一旦进行了此更改,我还将更改远程actor查找:

val remoteActor = actorSystem2.actorFor("akka://actorSystem1@localhost:2209/user/simplisticActor")
Run Code Online (Sandbox Code Playgroud)

至:

val remoteActor = actorSystem2.actorSelection("akka.tcp://actorSystem1@localhost:2209/user/simplisticActor")
Run Code Online (Sandbox Code Playgroud)

actorFor方法已被弃用,此外我认为你不放过.tcp的部分akka协议中查找远程演员.

进行这些更改,然后查看是否适合您.