Hi,

> Is it the same in Akka? ... What situations will make an Actor crash ? Is
it like above, due to unhandled/unexpected Exception in code ?

Whenever an exception is thrown from Actor methods it reaches our internals
and will be caught there. At that point, an internal system message is sent
to the actor's parent, telling him about the situation, and at the same
time suspending the child. At this point the parent  decides what to do by
returning Resume, Restart, Stop or Escalate.

If this would be ordinary threads, or a threadpool, the escaped exception
would end up at some unrelated place. What Akka does for you is to link
these processes together in a hierarchic tree, providing across-thread
failure notifications and options to restart or resume the faulty process.

> What if my supervision strategy for every child was to just to log the
unexpected error and *Resume* without stopping and restarting that Actor,
does this guarantee that the Actor will always be available in memory ones
created until I explicitly send it a "*Stop*" message ?

Yes, except if you explicitly provide an upper bound, like "maximum 5
failures per minute" which, if violated results in stopping the actor.

OTOH it is generally not recommended to use Resume but to use Restart
instead. At the point where the failure happened the actor might be in a
completely inconsistent state  because the exception might leave
half-written state changes

> And I can do what I have always done- log the exception and fix it later
without changing the Actor hierarchy structure of my application in memory ?

I don't understand this question.

> *Made up example*: Every UserActor's state will be User(id:String,
name:String, address:Address). If I had 10,000 UserActors in memory and if
I wanted to aggregate the results of all UserActors with name starting with
the string "*Jo*", In situations like this I would just to have the
guarantee that ones an Actor is created, it will always be available in
memory.

This is impossible to guarantee this way in the presence of exceptions.
While you might be able to keep alive the actors in memory (except JVM
crash) an exception might corrupt the values stored resulting in garbage.
Of course if you assume such exceptions will not happen then Resume will
keep these actors running.

-Endre


On Wed, Feb 24, 2016 at 1:35 AM, Chelios <[email protected]> wrote:

> Hi Guys,
>
> What makes an Actor crash ? Is it in the developer's code where the
> developer may have forgotten to handle an Exception ?
>
> I am trying to understand Akka supervision and previously I always used
> the Try catch blocks for the following situations
> - Critical IO failure situations
> - Exceptions on establishing connections with external APIs (databases or
> other services)
> - Or if I'm using an external library and it expects me to catch some
> Exception.
>
> In all the other cases I always try to validate requests and wrap invalid
> Request in Error message objects to send the response back to the client.
> Unknown Exceptions occurs if I had forgotten to write code to validate some
> error condition which will always get logged to fix the code later.
>
> Is it the same in Akka? ... What situations will make an Actor crash ? Is
> it like above, due to unhandled/unexpected Exception in code ?
>
> What if my supervision strategy for every child was to just to log the
> unexpected error and *Resume* without stopping and restarting that Actor,
> does this guarantee that the Actor will always be available in memory ones
> created until I explicitly send it a "*Stop*" message ? And I can do what
> I have always done- log the exception and fix it later without changing the
> Actor hierarchy structure of my application in memory ?
>
> What I'm trying to do is build a simple in-memory database with Akka where
> each Akka actor holds small bits of data
> *Made up example*: Every UserActor's state will be User(id:String,
> name:String, address:Address). If I had 10,000 UserActors in memory and if
> I wanted to aggregate the results of all UserActors with name starting with
> the string "*Jo*", In situations like this I would just to have the
> guarantee that ones an Actor is created, it will always be available in
> memory.
>
> --
> >>>>>>>>>> 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.
>



-- 
Akka Team
Typesafe - Reactive apps on the JVM
Blog: letitcrash.com
Twitter: @akkateam

-- 
>>>>>>>>>>      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