I am brand new to Akka and am trying to wrap my head around SupervisorStrategies
and child actor termination. I have several very similar concerns.
First off, my understanding is that if an actor creates another actor (via context.actorOf(...)
), then it is automatically the created actor's parent/supervisor. This is the only way an actor can be a parent of/supervisor of another actor.
If anything I have said above is incorrect, please begin by correcting me! But, assuming I'm more or less on track, then what happens when multiple parent actors create instances of the same child actor:
// Groovy pseudo-code.
class Fizz extends UntypedActor {
@Override
void onReceive(Object message) {
ActorRef buzz = context.system.actorOf(Props.create(Buzz), "buzz")
buzz.tell("Hello buzz!", self)
}
}
class Foo extends UntypedActor {
@Override
void onReceive(Object message) {
ActorRef buzz = context.system.actorOf(Props.create(Buzz), "buzz")
buzz.tell("Meh!", self)
}
}
In the above example, are Fizz
and Foo
parents to the same Buzz
actor instance, or two instances of Buzz
altogether? If it's multiple instances, can I assume that terminating one instance only terminates that instance? Or if Foo
terminates/stops its Buzz
instance, does that also terminate/stop Fizz
's instance?