Hi,
I am playing around with supervision in Java Akka 2.5.8 / 2.12.
I would like to have the ability to decorate any old actor's behaviour with retry logic.
I have the following:
A number of questions:
1) The exception thrown by the SupervisedActor is logged as an error:
11:43:00.542 [TestActorSystem-akka.actor.default-dispatcher-3] ERROR OneForOneStrategy - nullcom.tesco.payments.async.TestSupervisionDocs$RestartMe: null
at com.tesco.payments.async.TestSupervisionDocs$PrinterActor.lambda$createReceive$0(TestSupervisionDocs.java:66)
It's not clear to me that I've done things correctly - what's the 'null' for?
Also, is there a way to not have this logged as an error?
2) I had to use Backoff.onStop(...) rather than what seemed more intuitive Backoff.onFailure(...). Are there any issues I should be aware off with this?
3) In the SupervisedActor, I have overridden preRestart, which after a restart, sends the parent (supervisor) the failed message again, with the original sender.
sending to self rather than supervisor didn't work, don't understand why?
In any case is there a way to have the supervisor send the message again? Then the supervised actor would not need to be aware of its supervision nor know its parent is something special, nor contain part of the retry logic.
One way I can think off is to have the thrown exception contain the message, supervised actor and original sender, and then have supervisor send it to itself:
DeciderBuilder
.match(RestartMe.class, e -> {
System.out.println("RETRY caught------------------");
e.self.tell(e.msg, e.sender);
return restart();
})
However this still requires the SupervisedActor having some involvement in the process (throwing an exception with information specific to retry), and seems a bit ugly.
Help / thoughts much appreciated!
daz