Domanda

When is the supervisor strategy invoked ? Is it when the exception is thrown for an Actor. In below code :

@Override
public SupervisorStrategy supervisorStrategy() {

    System.out.println("supervisorStrategy");
   return strategy;
}

The println statement is not invoked when actor is created. Is this expected behaviour ?

È stato utile?

Soluzione

Unlike the not-to-well-named receive method, which is only called during Actor initialization to acquire the PartialFunction that will handle incoming messages, the supervisorStrategy method is used when failures occur. It is a regular method that does the work of deciding how to handle a failure in a descendant Actor.

Hmm... I just noticed you're using Java, so the part about receive is presumably different for you, but the supervisorStrategy statement still applies.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top