我正在尝试远程连接到不同的本地Akka ActorSystems
。我使用的是Scala 2.11.1和Akka 2.3.3。
我的application.conf看起来像这样:
akka {
loglevel = "DEBUG"
actor {
provider = "akka.remote-RemoteActorRefProvider"
}
remote {
enabled-transports = ["akka.remote.netty.tcp"]
netty.tcp {
hostname = "127.0.0.1"
port = 2552
}
}
}
localConf {
akka.remote.netty.tcp.port = 8448
}
remoteConf {
akka.remote.netty.tcp.port = 4224
}
Actor
非常简单。
import akka.actor._
class Consumer extends Actor {
def receive = {
case msg: String => println("Received: " + msg)
}
}
对于我正在使用的远程系统:
import akka.actor._
import com.typesafe.config.ConfigFactory
object RemoteStart extends App {
val config = ConfigFactory.load()
val system = ActorSystem("remoteSystem", config.getConfig("remoteConf").withFalBack(config))
val actor = system.actorOf(Props[Consumer], name = "consumer")
}
最后是我本地系统的代码:
import akka.actor._
import com.typesafe.config.ConfigFactory
object LocalStart extends App {
val config = ConfigFactory.load()
val system = ActorSystem("loaclSystem", config.getConfig("localConf").withFallBack(config))
val actor = system.actorSelection("akka.tcp://remoteSystem@127.0.0.1:4224/user/consumer")
actor ! "test"
}
我希望它会打印Received: test
。但相反,我收到错误消息。但我收到以下错误消息:
java.lang.NoSuchMethodError: akka.actor.ActorSelectionMessage.wildcardFanOut()Z
我错过了什么?
答案 0 :(得分:2)
您的类路径上有Akka的冲突版本。 NoSuchMethodErrors几乎总是由此引起的。
答案 1 :(得分:0)
您是否已将akka-remote模块添加到构建文件中?
http://doc.akka.io/docs/akka/2.3.4/intro/getting-started.html