I have situation when my actor A1 can be started in any seed node in cluster.
In some situation other actor A2 (possibly from another node) need to get ActorRef for A1. What is the best way to perform this?
1) I would like to avoid hardcode seed nodes network addresses.
2) I could run actor that subscribed for cluster events, but i don’t know how to force him to see nodes that was in cluster before it started.
3) I could try find actor by looping ActorSelection, but i still cant get seed nodes list from my akka.Cluster. Closest way that i found is:
Cluster cluster = Cluster.get(context().system());
SortedSet<Member>members = cluster.state().members();
Traversable<Member> filteredmembers = members.filter(_.status == MemberStatus.up());
But this is Scala syntax and classes, i have exception:
'_' used as an identifier (use of '_' as an identifier might not be supported in releases after Java SE 8)
How to avoid this exception?
With this, you can send messages to an actor within the cluster locally or remotely just by the actor’s path. It even do a simple routing for you when you have multiple cluster node running the same actor.