Akka Remoting Separate JVMs: Restarting ChildActor when JVM crashed?

141 views
Skip to first unread message

Harit Himanshu

unread,
Jun 22, 2015, 2:36:08 PM6/22/15
to akka...@googlegroups.com
Hello

I am learning Remoting and have a question. I am looking at example where remote actor is created programmatically. As per the typesafe activator sample, I read 

"Error handling, i.e. supervision, works exactly in the same way as if the child actor was a local child actor. In addtion, in case of network failures or JVM crash the child will be terminated and automatically removed from the parent even though they are located on different machines."

Question (assuming parent and child are on separate JVMs)
  1. If the child actor crashes the JVM(where it lived) and supervision strategy on parent(on a different JVM) is to Restart, will it start the entire ActorSystem for Child Actor? I guess not because ActorSystem was started as a separate process (by command-line).
  2. If 1. is true, how can we recover the Child Actor since the entire Actor System (where Child Actor lived) crashed?
Thank you
+ Harit Himanshu

Heiko Seeberger

unread,
Jun 22, 2015, 3:08:51 PM6/22/15
to akka...@googlegroups.com
You seem to confuse failure and termination. Failure happens when an actor throws an exception, e.g. during handling a message. Then it gets suspended and its parent needs to decide what to do, e.g. restart. Termination happens when an actor gets stopped, e.g. by itself, or – in the case of removing – when the remote failure detector decides that the other side is no longer reachable, which of course happens when the other JVM crashes. Termination has nothing to do with supervision, though the parent could watch the lifecycle of its children by calling `context.watch`. Hoping that helps.

Heiko

--

Heiko Seeberger
Twitter: @hseeberger

--

Heiko Seeberger
Twitter: @hseeberger

--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> 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 akka-user+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Harit Himanshu

unread,
Jun 22, 2015, 3:24:30 PM6/22/15
to akka...@googlegroups.com
Thanks a lot Heiko, That makes lot of sense.

So as I understand
  1. If the JVM (where child actor resides) terminates(or crashes), no supervision applies.
  2. The only way to recover then would be to start the process (JVM) with ChildActor again(manually or some other way) and parent Actor (in separate JVM) looks up for it and starts watching it again
Correct me if this understanding is wrong

Thank you
+ Harit Himanshu
You received this message because you are subscribed to a topic in the Google Groups "Akka User List" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/akka-user/SQF0wiObHGY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to akka-user+...@googlegroups.com.

Heiko Seeberger

unread,
Jun 23, 2015, 12:46:14 AM6/23/15
to akka...@googlegroups.com
1. yes
2. not exactly: it’s not possible to become a parent by looking up an actor, because each actor gets started by a parent actor (if you use ActorSystem.actorOf the system actor called guardian will be the parent)

So, one possible solution: Your parent actor watches its children which are deployed remotely; it also watches cluster events, in particular MemberUp; once it detects that too many children have died and there are spare remote cluster members nodes, it creates new children on these remote member nodes. BTW, that’s more or less what a cluster based pool router does, so you might not have to handle that yourself ...

Heiko

--

Heiko Seeberger
Twitter: @hseeberger

Reply all
Reply to author
Forward
0 new messages