It should be possible to restart without having the name collision of the
child. Do you override the preRestart method? By default preRestart stops
all children and waits (non-blocking) until they are terminated. This is
explained in What Restarting Means
<http://doc.akka.io/docs/akka/2.3.9/general/supervision.html#What_Restarting_Means>

Ryan's observation is important for another scenario, e.g. this will not
work:
val child = context.actorOf(Props[Child], "child")
context.stop(child)
context.actorOf(Props[Child], "child") // boom

Cheers,
Patrik




On Thu, Feb 12, 2015 at 3:36 AM, Ryan Tanner <[email protected]> wrote:

> From the documentation on stopping actors:
>
> Since stopping an actor is asynchronous, you cannot immediately reuse the
>> name of the child you just stopped; this will result in an
>> InvalidActorNameException. Instead, watch the terminating actor and
>> create its replacement in response to the Terminated message which will
>> eventually arrive.
>>
> http://doc.akka.io/docs/akka/2.3.9/scala/actors.html#Stopping_actors
>
> On Wednesday, February 11, 2015 at 10:58:58 PM UTC+7, Kane Lai wrote:
>>
>> Hi,
>>
>> I'm trying to manually restart the akka hierarchy because I'm
>> implementing something like hot-reload config mechanism.
>> I send a Kill to a top level actor and set the supervisor strategy for
>> ActorKilledException to Restart. Everything works fine so far.
>> Then during restart, in the top level actor constructor I recreate the
>> child actors like this. Then the InvalidActorNameException is seen. May I
>> know what's the usual practice to handle this? How could I recreate and
>> name the reborn child actors?
>> Thanks.
>>
>> val worker =
>>   context.actorOf(
>>     TcpServerWorker.props(
>>       self,
>>       config.operationSetConfig.tcpListenHost.get,
>>       config.operationSetConfig.tcpListenPort.get),
>>     "tcpServer")
>>
>>
>> Kane
>>
>  --
> >>>>>>>>>> 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 [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/d/optout.
>



-- 

Patrik Nordwall
Typesafe <http://typesafe.com/> -  Reactive apps on the JVM
Twitter: @patriknw

[image: Scala Days] <http://event.scaladays.org/scaladays-sanfran-2015>

-- 
>>>>>>>>>>      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 [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/d/optout.

Reply via email to