In a clustered environment, I have the seed node and node1 and node2.
From node1, I want to send a message to the Actor that was created on node2. The local path to this node on node2 is akka: MyAkkaSystem / user / AnActor.
Now I want to send a message from an actor from node1 to this particular actor using ActorSelection as follows:
var actorSystem = ActorSystem.Create("MyTestSystem"); var c = actorSystem.ActorSelection("/user/ConsoleReceiver"); c.Tell("Hello World");
On node2, the actor is created in this way:
var actorSystem = ActorSystem.Create("MyTestSystem"); var r = actorSystem.ActorOf(Props.Create<MessageReceiver>(), "ConsoleReceiver"); Console.WriteLine(r.Path); Console.ReadLine(); actorSystem.Terminate().Wait();
Unfortunately, this will not work, as the attempt ends in dead letters.
The HOCON configuration on node2 is as follows:
akka { actor { provider = "Akka.Cluster.ClusterActorRefProvider, Akka.Cluster" deployment { } } 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 } } cluster { #will inject this node as a self-seed node at run-time seed-nodes = ["akka.tcp:// webcrawler@127.0.0.1 :4053"] #manually populate other seed nodes here, ie "akka.tcp:// lighthouse@127.0.0.1 :4053", "akka.tcp:// lighthouse@127.0.0.1 :4044" roles = [crawler] } }
Like a seed node I use a beacon. In terms of connectivity, everything seems to work. Seed is found, and each node received receives a welcome message.
I thought that I have location transparency in the cluster and I can get the remote resources as if they were local.