Saturday, 11 July 2015

Looking up an Actor

Looking up actors

This example also showed one way to look up an actor:
val kenny = system.actorSelection("/user/Parent/Kenny")
As shown, you look up actors with the actorSelection method, and can specify a full path to the actor in the manner shown. The actorSelection method is available on anActorSystem instance and on the context object in an Actor instance.
You can also look up actors using a relative path. If kenny had a sibling actor, it could have looked up kenny using its own context, like this:

// in a sibling actor
val kenny = context.actorSelection("../Kenny")

No comments:

Post a Comment