How to set up a failover strategy when adding an actor to ActorySystem

I launch Play, and I add to the ActorSystem my main CarActorSupervisor, which then advances and creates other members in the hierarchy, etc.

@Singleton
class Jumpstart @Inject() (system: ActorSystem) {
   val carSupervisor = system.actorOf(CarSupervisor.props(.......))
}

Just for testing, I threw an exception in my CarSupervisor actor, and all child members were stopped, but CarSupervisor was not restarted.

Where can I set up the failure strategy of my main actor CarSupervisor?

This CarSupervisor actor connects to remote services, so I want him to try to restart and gradually increase the time (delay time) if he continues to fail.

So, in my Jumpstart class, I run 3 different supervisor classes.

But in case of a carSupervisor failure, it just continues, but does not try to restart it. Looking for some example code on how to do this, since I will have 3 actors created from the "root" actorSystem.

+4
source share

Source: https://habr.com/ru/post/1669077/


All Articles