Reputation: 59
I have a child akka actor belonging to the main application actor (parent). Now I want to get the reference of this parent actor in this child akka actor and use that reference to create another child actor of this main parent. Now my question lies here : Is it possible to use parent actor reference in a child actor to create another child actor ? Any help would be highly appreciated. Thanks
Upvotes: 0
Views: 607
Reputation: 35443
No, it's not possible to do what you are describing, and it wouldn't be advisable either. An actor's reference to it's parent (via context.parent
) is merely an ActorRef
, so you can't use that to create another child from that parental ref as you don't have access to it's ActorContext
. You could however request that your parent create a new child by sending it a custom message that the parent handles and creates a new child as a result. That's probably your best bet if you need one child to be able to signal to the parent that a sibling needs to be created.
Upvotes: 2