I have a server-client architecture where there are many clients and one server. I'd like to create an actor in each client and put them on the server actor system.
I tried to do this dynamically. After creating the actor remotely (which I'm not sure is successful) I can't select it. Here is my server:
class TestActorSystem {
val system = ActorSystem("testSystem", ConfigFactory.load("server.conf"))
def shutdown = system.shutdown()
Server Config:
akka {
#loglevel = "DEBUG"
actor {
provider = "akka.remote.RemoteActorRefProvider"
}
remote {
enabled-transports = ["akka.remote.netty.tcp"]
netty.tcp {
hostname = "127.0.0.1"
port = 2552
}
log-sent-messages = on
log-received-messages = on
}
}
Here is my client:
class Client(id: String, remoteAddress: Address) {
def this(id: String) = {
this(id, Address("akka.tcp", "testSystem", "127.0.0.1", 2552))
}
implicit val timeout = Timeout(600.seconds)
val conf = ConfigFactory.load()
val system = ActorSystem("client", ConfigFactory.load("client.conf"))
val remote = remoteAddress.toString
private val broadcaster = system.actorSelection(Props[MyActor].withDeploy(Deploy(scope = RemoteScope(remoteAddress))), name = "joe")
def shutdown() = system.shutdown
def send = {
val c = system.actorSelection("akka.tcp://testSystem@127.0.0.1:2552/user/joe")
c ! "simple message"
}
}
Client Config:
akka {
#log-config-on-start = on
stdout-loglevel = "DEBUG"
loglevel = "DEBUG"
actor {
provider = "akka.remote.RemoteActorRefProvider"
}
remote {
enabled-transports = ["akka.remote.netty.tcp"]
log-sent-messages = on
log-received-messages = on
netty.tcp {
hostname = "127.0.0.1"
port = 0
}
}
}
I start the server and then run the client, here is what I think is the relevant error message:
[INFO] [04/04/2014 09:32:09.631] [testSystem-akka.actor.default-dispatcher-17] [akka://testSystem/user/joe] Message [java.lang.String] from Actor[akka://testSystem/deadLetters] to Actor[akka://testSystem/user/joe] 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'.
I've also tried to create remote actors through my configuration file with similar results. Any idea appreciated! I'm not sure if this matters but I'm running this code through my IDE.