This is how it is supposed to work: If persistence of an event fails, the persistent actor will be stopped. This can be customized by handling `PersistenceFailure` in `receiveCommand`. The actor is stopped by default because it throws an `ActorKilledException` if the `PersistenceFailure` message is not handled.
That means that you can handle PersistenceFailure and throw another exception that will restart the actor. It might be good to not restart the actor immediately, because it will probably fail again. Then you can implement backoff by doing something like: https://github.com/akka/akka/blob/v2.3.7/akka-contrib/src/main/scala/akka/contrib/pattern/ClusterSharding.scala#L880 However, I think we have a bug related to PersistenceFailure: https://github.com/akka/akka/issues/16187 /Patrik On Fri, Nov 28, 2014 at 1:59 PM, Olivier Mélois <[email protected]> wrote: > Hello, > > I'm currently using akka-persistence for a project, with the MongoDB > connector <https://github.com/ironfish/akka-persistence-mongo>. I'd like > my persistent actor to attempt restarting a certain number of times if it > fails to connect to the database. However, as I tried to set a custom > SupervisorStrategy to its parent (the guardian), I noticed that the > ActorInitializationException thrown during the instantiation (eg if the DB > is not started) does not appear to escalate in up to my PersistentActor (it > appears to be thrown by the CasbahJournal, which is an actor implemented in > the MongoDB connector, but I'm not sure how it is programmatically related > to my PersistentActor). > > My question is : when you have a persistent actor, is there a generic way > to supervise the failures that might happen during the connection to the > backend ? If there isn't, is there a clean way to manually restart an actor > ? > > Thank you ! > > -- > >>>>>>>>>> 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 -- >>>>>>>>>> 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.
