Reputation: 388
I am working on one application which demands for akka clustering. I am able to create akka cluster and create actors and pass them messages.
Following is my configuration:
relay.system {
akka {
loglevel = "INFO"
actor {
provider = "akka.cluster.ClusterActorRefProvider"
}
remote {
log-remote-lifecycle-events = on
netty.tcp {
hostname = "vm1.iviws.local"
port = 3503
}
}
cluster {
seed-nodes = [
"akka.tcp://[email protected]:3503"
"akka.tcp://[email protected]:3503"
]
auto-down-unreachable-after = 30s
}
}
}
Following is sample code with which I am able to create actors on remote node.
import com.typesafe.config.ConfigFactory
val config = ConfigFactory.load
val akkaConfig = config.getConfig("relay.system")
val actorSystem = ActorSystem("RelaySystem", akkaConfig)
val roundRobinPool = RoundRobinPool(nrOfInstances = 4)
val clusterRouterSettings = ClusterRouterPoolSettings(totalInstances = 4, maxInstancesPerNode = 2, allowLocalRoutees = true, useRole = None)
val clusterRouterPool = ClusterRouterPool(roundRobinPool, clusterRouterSettings)
val router = actorSystem.actorOf(clusterRouterPool.props(Props[Logger]))
Above code creates remote actor with help of router.
If I try to create actor without help of router: val actorA = actorSystem.actorOf(Props[Logger])
Then actor is created on my local system.
Is there any way to create actors on remote node without using router or without telling remote node where I want to create actor?
Basically what I want is: val actorA = actorSystem.actorOf(Props[Logger])
should create actor on any random node in cluster(including local node).
Upvotes: 0
Views: 309