尝试运行mykka应用程序时出现此错误:
[ERROR] [06/30/2014 15:58:14.591] [Thread-3] [RemoteActorRefProvider] 查找地址时出错[akka://FooPar0@127.0.0.1:2552] akka.remote.RemoteTransportException:未加载传输 protocol:[akka],可用协议:[akka.tcp] at akka.remote.Remoting $ .localAddressFo rRemote(Remoting.scala:88) ...
我的sbt项目有以下build.sbt:
name:=" FooPar"
版本:=" 0.1"
scalaVersion:=" 2.11.1"
解析器+ =" Typesafe Repository"在 " http://repo.typesafe.com/typesafe/releases/"
解析器+ =" Sonatype发布"在 " http://oss.sonatype.org/content/repositories/releases"
libraryDependencies + =" com.typesafe.akka" %%" akka-actor" %" 2.3.4"
libraryDependencies + =" com.typesafe.akka" %%" akka-remote" %" 2.3.4"
libraryDependencies + =" org.scalacheck" %%" scalacheck" %" 1.11.4" % "测试"
最后,我的应用程序生成的配置字符串如下所示:
akka { actor { provider = "akka.remote.RemoteActorRefProvider" } remote { enabled-transports = ["akka.remote.netty.tcp"] netty.tcp.hostname = "10.126.13.61" netty.tcp.port = 2552 netty.tcp.message-frame-size = 20 MiB //netty.tcp { // write-buffer-high-water-mark = 148000b // send-buffer-size = 148000b // receive-buffer-size = 148000b //} } event-handlers = [] loglevel=WARNING } my-custom-dispatcher { // type = PinnedDispatcher executor = thread-pool-executor # 10 years should be enough // thread-pool-executor.keep-alive-time = 315360000s # note that disabling core timeout altogether doesn't work # until ticket 2856 is fixed thread-pool-executor.allow-core-timeout = off mailbox-type = "akka.dispatch.UnboundedDequeBasedMailbox" }
有人可以帮我找到问题吗?我在这里遵循本指南http://doc.akka.io/docs/akka/2.3.4/scala/remoting.html,但似乎我的配置文件应该是
作为对马里奥的回应:
我从上面列出的配置字符串中实例化ActorSystem,然后通过以下代码实现:
private var system: Option[ActorSystem] = None
def getSystem(machinefile: String) = synchronized {
system match {
case None =>
system = Some(ActorSystem("FooPar" + indexOf(hostName, machinefile),
ConfigFactory.parseString(conf))); system
case Some(sys) => system
}
}
也就是说,我没有明确地创建Address
个对象。
答案 0 :(得分:0)
在创建akka.actor.Address
的实例时,这看起来很像问题。要使远程处理工作,第一个参数必须是"akka.tcp"
而不是"akka"
:
val addr = Address("akka.tcp", "actorSystem", hostname, port)
然后当你想获得对演员的引用时:
val path = RootActorPath(addr) / "user" / "actorName"
val actorRef = context.actorSelection(path)
(请注意context
也可能是system
)
正如评论中所述,由于您正在使用actorFor
,请尝试在网址中使用akka.tcp://
代替akka://
。