I'm creating a sample with Akka.Cluster
with three nodes A, B and C where A is the lighthouse. So far, from the logs, the cluster works fine when there are no actors or when actors are local (created with spawn
and spawnOpt
). I want to create an actor from B and access it from C.
With
let _ = spawne system "r-actor" <@ actorOf (fun msg -> printfn "Received: %s" msg) @> []
I get
2016-08-31 01:59:00.1185|INFO|Akka.Actor.EmptyLocalActorRef|Message String from akka://calculatorSystem/deadLetters to akka://calculatorSystem/user/r-actor was not delivered. 1 dead letters encountered.
Using
let r = FromConfig.Instance :> RouterConfig |> SpawnOption.Router
let _ = spawne system "r-actor" <@ actorOf (fun msg -> printfn "Received: %s" msg) @> [r]
throws the exception
An unhandled exception of type
Akka.Configuration.ConfigurationException
occurred in Akka.dll
Additional information:Configuration problem while creating [akka://calculatorSystem/user/r-actor] with router dispatcher [akka.actor.default-dispatcher] and mailbox and routee dispatcher [akka.actor.default-dispatcher] and mailbox [].
The test function on Node C is
let rec calculate content =
printfn "Processing %s" content
let actor = select "/user/r-actor" system
actor <! content
let text = Console.ReadLine()
if text <> "quit" then
calculate text
calculate "sample1"
HOCON (Node B)
akka {
actor {
provider = "Akka.Cluster.ClusterActorRefProvider, Akka.Cluster"
serializers {
wire = "Akka.Serialization.WireSerializer, Akka.Serialization.Wire"
}
serialization-bindings {
"System.Object" = wire
}
deployment {
/user/add {
router = round-robin-pool
nr-of-instances = 10
cluster {
enabled = on
max-nr-of-instances-per-node = 10
allow-local-routees = off
}
}
/user/r-actor {
router = round-robin-pool
nr-of-instances = 10
cluster {
enabled = on
max-nr-of-instances-per-node = 10
allow-local-routees = off
}
}
}
}
remote {
log-remote-lifecycle-events = DEBUG
log-received-messages = on
helios.tcp {
transport-class = "Akka.Remote.Transport.Helios.HeliosTcpTransport, Akka.Remote"
applied-adapters = []
transport-protocol = tcp
hostname = "127.0.0.1"
port = 0
}
}
loggers = ["Akka.Logger.NLog.NLogLogger,Akka.Logger.NLog"]
cluster {
seed-nodes = [
"akka.tcp://calculatorSystem@127.0.0.1:7001"
]
roles = ["add-service"]
auto-down-unreachable-after = 10s
}
}
How do I create an actor that can be called by another node in the cluster?