Hi Sridhar,
> class CA2 {
>
> val ca2Refs = Set.Empty[ActorRef]
> receive => {
> case messageFromMaster => {
> if (ca2Refs.isEmpty) {
> val ca2Ref = context.actorOf(Props[CA2])
> context.watch(ca2Ref)
> ca2Refs += ca2Ref
> ca2Ref ! message
> }
> }
> case messageFromCA2 => {
> ca2Refs -= ca2Ref
> }
>
Does the line above guarantee that the child was actually terminated? If
you remove it, but it is still running that might be a problem (depending
on what you want to achieve).
> case Terminated => {
> ca2Refs -= ca2Ref
> }
> }
> }
>
>
> Question I have is, is this within the "Normal practices" of akka? And
> will this account for actors that are restarted? As in if a particular
> child actor CA2 is restarted, will CA1 receive the Terminated message?
> Would appreciate your feedback.
>
Restarts do not result in Terminated messages, since the actor is not
terminated -- it is restarted. A supervisor directive Stop, an explicit
context.stop(child) or child ! PoisonPill results in the child being
stopped and in a Terminated message.
Also in your code, when CA1 is restarted the ca2Refs variable will be
initialized to the empty set although the children are still there
(although they have been restarted recursively). See this for details on
how restart works:
http://doc.akka.io/docs/akka/2.2.3/general/supervision.html#What_Restarting_Means
-Endre
>
> Regards,
> Sridhar.
>
> --
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ: http://akka.io/faq/
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/groups/opt_out.
>
--
Akka Team
Typesafe - The software stack for applications that scale
Blog: letitcrash.com
Twitter: @akkateam
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://akka.io/faq/
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/groups/opt_out.