That sample looks suspiciously like calling actor internals from another
thread (saveStateOnDb from inside the future) which you should never do.
See explanation in the docs here:
http://doc.akka.io/docs/akka/current/scala/general/jmm.html#futures-and-the-java-memory-model

One way to simplify is to use the pipe-pattern and get the future result as
a message to your actor, if the future is failed the exception will be
wrapped in a akka.actor.Status.Failure and that is sent to the actor and
you can deal with it in any way you'd like in the actor receive logic.

If the correct reaction to it is to throw or stop actor or send a message
to some other actor depends on the specific problem you are solving. If the
actor models a request response then the right thing would be to stop and
or tell someone about the failure, if it models a remote API where multiple
requests flows through it you wouldn't want to stop it. If the failure
could have damaged the internal state you would want to restart etc.

--
Johan
Akka Team



On Mon, Aug 21, 2017 at 3:02 PM, Isaias Barroso <[email protected]>
wrote:

> Hi, all.
>
> Suppose I have an actor and I need to interrupt an execution based on a
> Future exception, for example, like at that pseudo code:
> https://gist.github.com/isaias/0445b5c32fd1905aba8cd18294672e25
>
> Should throw the exception and let supervisor decide what to do? Stop the
> Actor?
>
> Thanks a lot.
>
>
>
>
>
> --
> >>>>>>>>>> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
>>>>>>>>>>      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 [email protected].
To post to this group, send email to [email protected].
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