Thanks for the fast reply! I am aware of CoordinatedShutdown, and I love it - it's exactly what I've been re-coding for every Akka system ;-)
For the special case of ShardedRegion however I did not find a way to do the sequence I described in my original post, specifically giving time to sharded entities to finish their current work *after* the region stopped accepting new commands. As far as I can see, coordinated shutdown sends GracefulShutdown to the ShardRegion in PhaseClusterShardingShutdownRegion, which then stops the ShardRegion with its children. If I drain the shardede entities of their work before that - e.g. in PhaseServiceRequestsDone - then what prevents other cluster nodes from sending new commands to them afterwards or even starting new entities on the node that is shutting down? Am 18.04.2017 um 07:33 schrieb Konrad Malawski: > What you describe is exactly a feature we just rolled out in Akka 2.5.0 :-) > Docs here: > http://doc.akka.io/docs/akka/2.5/scala/actors.html#Coordinated_Shutdown > It also handles other parts of Akka, such as cluster singletons, Akka > HTTP and more. > > Akka 2.5 is binary compatible with 2.4 (except if a library touched some > specific internals / private APIs - see the release notes for details), > so you should be able to quickly hop onto it :-) > > Happy hakking! > > -- > Konrad `ktoso` Malawski > Akka <http://akka.io> @ Lightbend <http://lightbend.com> > > On 18 April 2017 at 14:31:24, Arno Haase > ([email protected] > <mailto:[email protected]>) wrote: > >> When shutting down an ActorSystem, I would like to shut down a >> ShardRegion in three phases to ensure consistency: >> >> 1. Prevent sharded entities from receiving any new commands >> 2. Let the sharded entities finish their work >> 3. Actually shut down the ShardRegion, stopping all sharded entities and >> allowing other shards to start this shard's entities >> >> To give some context, in my case command processing involves some >> interaction between sharded entities and other actors (e.g. updating an >> ElasticSearch index), so step 2 involves more than just stopping the >> sharded entity actor. >> >> This looks like a common problem, but I found no API for doing step 1 >> without stopping sharded entity actors. In particular, sending >> GracefulShutdown to the ShardRegion appears to do 1. and 3. without >> allowing the application code to do 2. >> >> Am I missing something? Any help is appreciated. >> >> - Arno >> >> >> -- >> >>>>>>>>>> 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] >> <mailto:akka-user%[email protected]>. >> To post to this group, send email to [email protected] >> <mailto:[email protected]>. >> Visit this group at https://groups.google.com/group/akka-user. >> For more options, visit https://groups.google.com/d/optout. -- >>>>>>>>>> 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 https://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
