我想兩個遠程連接到不同的本地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://[email protected]:4224/user/consumer")
actor ! "test"
}
我預計它將打印Received: test
。但相反,我收到錯誤消息。但相反,我收到以下錯誤消息:
java.lang.NoSuchMethodError: akka.actor.ActorSelectionMessage.wildcardFanOut()Z
我錯過了什麼?
其實我的classpath中有許多庫的衝突版本。刪除SBT緩存並重新導入真正的nessecary庫後,這一切都運行得很完美。 –