Stopping the singleton actor is not a good idea because it will not be started again unless you stop the actor system that it was running on. I see two alternatives.
1) Stop the SingletonManager and later start it again. 2) Introduce another shallow parent actor to the actual singleton actor. The parent actor is always running, and would delegate to the child when active, otherwise just be there as an idle placeholder until it's time to start the child (the actual singleton) again. 2 is probably best /Patrik On Tue, Jun 20, 2017 at 10:50 PM, <[email protected]> wrote: > Hello, > > We are running Akka 2.4.18. We have a singleton that is created on all > nodes in the cluster(for example three nodes). At some point in the life > time of the singleton we no longer need it on any of the nodes but later > need to recreate it. Is there a way to stop the singleton on all nodes then > recreate it later. What we have found is if we stop(context stop self) the > singleton actor on one node and then try to recreate the singleton on the > same node using the code below the ClusterSingletonManager still thinks the > singleton exists (i.e ""VideoTranscodeSingletonSagaSubscriber: > VideoTranscodeSingletonSaga actor already exists.") and the proxy we > create can not find it. From what I can tell the ClusterSingletonManager > has no idea that the singleton has been stopped using "context stop self" > inside the singleton and somehow messages being sent to the proxy can not > find the singleton anymore. > > Try { > context.system.actorOf( > ClusterSingletonManager.props( > singletonProps = props, > terminationMessage = PoisonPill, > settings = ClusterSingletonManagerSettings(context.system) > ), > name = singletonName > ) > } match { > case Success(videoTranscodeSingletonSaga: ActorRef) => > log.debug("VideoTranscodeSingletonSagaSubscriber: > VideoTranscodeSingletonSaga created.", Map("singletonName" -> singletonName)) > case Failure(ex) => ex match { > case InvalidActorNameException(ex) => > log.debug("VideoTranscodeSingletonSagaSubscriber: > VideoTranscodeSingletonSaga actor already exists.", Map("singletonName" -> > singletonName)) > case _ => > log.error("VideoTranscodeSingletonSagaSubscriber failed to create or > find actor.", Map("singletonName" -> singletonName)) > > } > } > > > -- > >>>>>>>>>> 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. > -- Patrik Nordwall Akka Tech Lead Lightbend <http://www.lightbend.com/> - Reactive apps on the JVM Twitter: @patriknw -- >>>>>>>>>> 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.
