Thanks for quick reply. I was experimenting with that problem, but then had unexpected hardware problems :/
W dniu niedziela, 5 kwietnia 2015 18:28:25 UTC+2 użytkownik Patrik Nordwall napisał: > > Hi Max, > > 3 apr 2015 kl. 13:25 skrev Maxymilian Śmiech < > [email protected] <javascript:>>: > > Hi, > > I want to use ClusterSingletonManager, but it is not possible to set > supervision strategy for its child (like with Router). What should I do? > > - copy ClusterSingletonManager implementation and add parameter > - override ClusterSingletonManager (factory methods from companion > object will be unusable) > > I know it is possible to hack this with dummy Router (or my dummy > intermediate actor) but that will complicate actor paths. > > > Adding another supervisor actor that creates the "real" singleton instance > is what I would recommend. If paths are of importance that parent actor > could forward all messages to its child. > Actually, not only paths for that singleton actor but also for its children are used (I have some hierarchy of "singletons"). Maybe my design is not good, that was my first attempt to use ClusterSingletonManager. > My use case: detect ActorInitializationException (because of errors when > parsing Config options) and shutdown application. I want to be reliably > notified when my singleton actor stops (any errors). > > > Sounds like you should use watch for this. No need for supervision. > ClusterSingletonManager creates MySingletonActor. During initialization MySingletonActor throws some Exception. It is wrapped by ActorInitializationException and reported to ClusterSingletonManager. Default supervision strategy stops MySingletonActor. There is no way to reliably get ActorRef for MySingletonActor - it may be already stopped. It looks to me that the only actor that can observe full life cycle of MySingletonActor is its supervisor. In other cases there will be race with actorSelection and Identify message. Also, ClusterSingletonManager performs handoff, so watching is not enough to detect why MySingletonActor stopped. My current solution is to try ... catch MySingletonActor initialization code and shutdown() in case of Exception. I also override postStop() and check if actor was stopped using my custom terminationMessage (used for handoff). If not, I assume there was some "default-strategy-stopping" exception (ActorKilledException, DeathPactException) and shutdown. It would be better to use supervision, but I must redesign my singleton actors first to allow for intermediate supervising actor. > > /Patrik > > > Is it possible to reliably detect that situation without injecting > Supervision strategy into ClusterSingletonManager? > > thanks! > Max > > -- > >>>>>>>>>> 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] <javascript:>. > To post to this group, send email to [email protected] > <javascript:>. > Visit this group at http://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 http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
