我正在以编程方式创建远程 akka 演员。
以下是程序 -
package remoting.programatic.demo
import akka.actor.{ActorSystem, Props}
import com.typesafe.config.ConfigFactory
import remoting.config.demo.RemoteActor
object RemoteActorApp extends App {
val system = ActorSystem("RemoteNodeApp", ConfigFactory.load().getConfig("RemoteProgrammatically"))
val remoteActor = system.actorOf(Props[RemoteActor], name = "remoteActorAddr")
remoteActor ! "Hello!"
val actorSelection = system.actorSelection("akka.tcp://RemoteNodeApp@localhost:2553/user/remoteActorAddr")
Thread.sleep(4000L)
actorSelection ! "Hello!"
}
配置是 -
RemoteProgrammatically {
akka {
actor {
provider = "akka.remote.RemoteActorRefProvider"
deployment {
/remoteActorAddr {
remote = "akka.tcp://RemoteNodeApp@localhost:2553"
}
}
}
remote {
enabled-transports = ["akka.remote.netty.tcp"]
netty.tcp {
hostname = "localhost"
port = 2553
}
}
}
}
运行程序后的输出是 -
[INFO] [12/27/2017 10:37:30.053] [main] [akka.remote.Remoting] Starting remoting
[INFO] [12/27/2017 10:37:30.378] [main] [akka.remote.Remoting] Remoting started; listening on addresses :[akka.tcp://RemoteNodeApp@localhost:2553]
[INFO] [12/27/2017 10:37:30.379] [main] [akka.remote.Remoting] Remoting now listens on addresses: [akka.tcp://RemoteNodeApp@localhost:2553]
[INFO] [12/27/2017 10:37:30.418] [RemoteNodeApp-akka.actor.default-dispatcher-14] [akka://RemoteNodeApp/deadLetters] Message [java.lang.String] from Actor[akka://RemoteNodeApp/user/remoteActorAddr#-766312407] to Actor[akka://RemoteNodeApp/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'.
[INFO] [12/27/2017 10:37:34.419] [RemoteNodeApp-akka.actor.default-dispatcher-14] [akka://RemoteNodeApp/deadLetters] Message [java.lang.String] from Actor[akka://RemoteNodeApp/user/remoteActorAddr#-766312407] to Actor[akka://RemoteNodeApp/deadLetters] was not delivered. [2] 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'.
我发送给演员的消息总是进入死信。看起来remoteActorAddr
在 RemoteNodeApp 演员系统上没有成功创建。任何想法为什么不创建演员以及为什么消息总是变成死信。谢谢。