如何给出找到远程参与者的准确路径



我正在学习本教程

http://alvinalexander.com/scala/simple-akka-actors-remote-example

我正在按原样运行,但我的程序没有运行,它给了我错误,我对这一行感到困惑:

val remote = context.actorFor("akka://HelloRemoteSystem@127.0.0.1:5150/user/RemoteActor")

我必须用什么来代替"用户"?当我写完整的路径到最后,例如:

 val remote = context.actorFor("akka://HelloRemoteSystem@127.0.0.1:5150/sw/opt/programs/akka/akkaremoting/RemoteActor")

和运行hellololocal和helloremote都会在查找该地址的actor时出错。

如果我按原样编写代码,就会出错helloremote错误:

[INFO] [10/27/2014 16:06:23.736] [HelloRemoteSystem-akka.actor.default-dispatcher-2] [akka://HelloRemoteSystem/deadLetters] Message [java.lang.String] from Actor[akka://HelloRemoteSystem/user/RemoteActor#911921687] to Actor[akka://HelloRemoteSystem/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'.
^Csarawaheed@ubuntu:/opt/ifkaar/programs/akka/akkaremoting/helloremote$ sbt run
[info] Loading project definition from /opt/ifkaar/programs/akka/akkaremoting/helloremote/project
[info] Set current project to helloremote (in build file:/opt/ifkaar/programs/akka/akkaremoting/helloremote/)
[info] Running HelloRemote 
Remote Actor receive messgage : The remote actor is alive  
[INFO] [10/27/2014 17:24:06.136] [HelloRemoteSystem-akka.actor.default-dispatcher-2] [akka://HelloRemoteSystem/deadLetters] Message [java.lang.String] from Actor[akka://HelloRemoteSystem/user/RemoteActor#-792263999] to Actor[akka://HelloRemoteSystem/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'.

hellocal错误:

[INFO] [10/27/2014 16:06:23.736] [HelloRemoteSystem-akka.actor.default-dispatcher-2] [akka://HelloRemoteSystem/deadLetters] Message [java.lang.String] from Actor[akka://HelloRemoteSystem/user/RemoteActor#911921687] to Actor[akka://HelloRemoteSystem/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'.
^Csarawaheed@ubuntu:/opt/ifkaar/programs/akka/akkaremoting/helloremote$ sbt run
[info] Loading project definition from /opt/ifkaar/programs/akka/akkaremoting/helloremote/project
[info] Set current project to helloremote (in build file:/opt/ifkaar/programs/akka/akkaremoting/helloremote/)
[info] Running HelloRemote 
Remote Actor receive messgage : The remote actor is alive  
[INFO] [10/27/2014 17:24:06.136] [HelloRemoteSystem-akka.actor.default-dispatcher-2] [akka://HelloRemoteSystem/deadLetters] Message [java.lang.String] from Actor[akka://HelloRemoteSystem/user/RemoteActor#-792263999] to Actor[akka://HelloRemoteSystem/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'.

远程akka actor路径由以下组件组成:

protocol:actor system name:server address:remoting port:root path:actor path + name

因此,对于第一个例子,这些组件最终是:

protocol = akka://
actor system name = HelloRemoteSystem
server address = 127.0.0.1
remoting port = 5150
root path: user
actor path + name = RemoteActor

您在自定义actor代码中启动的所有actor都将汇总到user根目录下。Akka为系统级参与者使用了另一个名为system的根。这些参与者与用户的自定义应用程序所需的自定义参与者属于不同的层次结构和监督方案。因此,user应该始终是示例中自定义RemoteActor的路径的一部分。然后,由于RemoteActor作为具有name = "RemoteActor"的顶级参与者(没有直接主管,从system开始,而不是从另一参与者的context开始)启动,所以它将在路径/user/RemoteActor下滚动。因此,将所有这些放在一起,用于远程查找该参与者的路径是示例代码中给出的路径:

"akka://HelloRemoteSystem@127.0.0.1:5150/user/RemoteActor"

您不需要更改"用户"

如果你查看akka的文档,你会发现"user"是每个参与者系统的一个子目录,其中包含所有与用户相关/用户创建的参与者,而不是你的用户名称:)

相关内容

  • 没有找到相关文章

最新更新