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:
https://pastebin.com/3qV8kDfz

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

-- 
*****************************************************************************************************
** New discussion forum: https://discuss.akka.io/ replacing akka-user 
google-group soon.
** This group will soon be put into read-only mode, and replaced by 
discuss.akka.io
** More details: https://akka.io/blog/news/2018/03/13/discuss.akka.io-announced
*****************************************************************************************************
>>>>>>>>>> 
>>>>>>>>>>      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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to