akka-supervision

How to escalate top-most supervisors in Akka?

扶醉桌前 提交于 2020-01-24 19:08:31
问题 I have the following top-level (“parent-most”) actor: // Groovy pseudo-code class Master extends UntypedActor { ActorRef child1 ActorRef child2 ActorRef child3 ActorRef backup @Override void onReceive(Object message) throws Exception { if(message instanceof Terminated) { Terminated terminated = message as Terminated if(terminated.actor != backup) { terminated.actor = backup } else { // TODO: What to do here? How to escalate from here? } } else { child1.tell(new DoSomething(message), getSelf()

Top-level Akka actor escalation and shutdown hooking

泪湿孤枕 提交于 2019-12-13 01:12:36
问题 In my Akka system there is a top-level ("root") actor, Initializer , from which all other actors come from. There is also an actor, Destroyer , that is responsible for shutting down the system gracefully when it receives a Destroy message. There are several conditions under which an actor would send a Destroy to the Destroyer , but those don't really matter here. I would now like to implement functionality in Initializer 's SupervisorStrategy where, if it can't handle a failure/exception

Prevent akka actor from restarting child actor

白昼怎懂夜的黑 提交于 2019-12-10 20:00:04
问题 I'm trying to get an actor Worker to not restart its child actor SubWorker when it's restarted by it's own supervisor Mngr . I've been unsuccessful even after overriding the preRestart() and postRestart in Worker . The logs still show that SubWorker is till being restarted. I'm new to Akka and Actor model, I don't know what I'm doing wrong. case class Start() case class ThrowExp() class Mngr extends Actor { val log = Logging(context.system, this) override def preStart(): Unit = { self ! Start

Akka Supervisor Strategy - Correct Use Case

风流意气都作罢 提交于 2019-12-10 15:34:23
问题 I have been using Akka Supervisor Strategy to handle business logic exceptions. Reading one of the most famous Scala blog series Neophyte, I found him giving a different purpose for what I have always been doing. Example: Let's say I have an HttpActor that should contact an external resource and in case it's down, I will throw an Exception, for now a ResourceUnavailableException . In case my Supervisor catches that, I will call a Restart on my HttpActor, and in my HttpActor preRestart method,

Akka supervisor managing supervisors

假如想象 提交于 2019-12-07 18:20:26
问题 I reckon there might be a broader question of application design using Akka hidden in here but I'll ask how does one set up a supervision tree where a "kernel" or "top" supervisor might supervise children that are other supervisors which supervisor workers? 回答1: You might start with a declarative supervisor on the top level val kernel = Supervisor( SupervisorConfig( OneForOneStrategy(List(classOf[Exception]), 3, 1000), Supervise( actorOf[Module1], Permanent) :: Supervise( actorOf[Module2],

In AKKA does calling shutdown on a supervisor stop all the actors it's supervising?

情到浓时终转凉″ 提交于 2019-12-06 23:52:14
问题 Let's say I have a supervisor that has linked 2 actors. When my app shutsdown I want to shutdown those actors gracefully. Does calling supervisor.shutdown() stop all the actors or do I still need to stop my actors manually? gracias 回答1: Stopping a supervisor (calling Supervisor.stop() ) stops all linked (supervised) actors: final class SupervisorActor{ ... override def postStop(): Unit = shutdownLinkedActors However, when you want to shutdown all actors in the system gracefully, there's