I need to determine whether the sender of a message was one of the local or remote actors in the Akka cluster. At present the only way I've found to do this is
def isLocal(sndr: ActorRef) = sndr.path.address.toString == context.system.toString
What's a better way?
I'm using Akka 2.3
Update: To explain why I want to do this, in case there is a way to avoid the issue entirely.
On each node a router manages a number of actors to do work. The worker actors send results back to the local master actor and are assigned new jobs via the sender reference. Master actors also periodically send results to the master actors of other nodes, ensuring that data is randomly 'mixed' between masters on different nodes. In the case of data arriving from a remote actor, the receiving master should not attempt to allocate new work. It's essentially an implementation of an islands method with mixing.