Hi Mark,
Rafal has already covered the reasoning and I just wanted to direct some
more information into this thread.
You have to remember that the exact model you ask for does not really fit
concurrent / distributed systems - exceptions and stack traces are
inherently bound to a thread - the one executing the code, while Actors
jump around threads and it's all async.

Firstly, start out by reading this guide about supervision in Akka:
http://doc.akka.io/docs/akka/snapshot/general/supervision.html
Supervision is very much at the core of Akka so "getting it" will help you
a lot down the line with the project.

Also, here's a short guide about Actors and Exceptions:
http://doc.akka.io/docs/akka/current/scala/actors.html#actors-and-exceptions

Happy hakking!


On Tue, Oct 14, 2014 at 11:25 PM, Rafał Krzewski <rafal.krzew...@gmail.com>
wrote:

> This is not how things work in Akka-land :) Exceptions thrown in an Actors
> receive method are reported to it's supervisor actor which may choose to
> escalate it (among other choices), but that means that the supervisor
> itself terminates abnormally throwing an exception that is passed in turn
> to it's own supervisor. Its no wonder that the Guardian actor refuses to
> escalate the exception, because it would make your whole ActorSystem
> inoperable.
>
> I can see two paths from here: you could follow the error kernel pattern
> and use intermediate actor: Let your Spring controller create a "safe"
> actor, that will spawn a child actor to do the "dangerous" work and handle
> the child's failure appropriately. The second choice is not letting the
> exception to escape receive method: catch it and send a message that
> describes the error to the Spring controller.
>
> Hope that helps,
> Rafał
>
> W dniu wtorek, 14 października 2014 22:03:19 UTC+2 użytkownik Mark
> Kaberman napisał:
>
>> I have Spring MVC controller class in my application which creates top
>> level Akka actor (via Spring). When this actor throws an exception I expect
>> it to be handled by the controller, but in my case the actor simply times
>> out after 5 sec. I tried to implement my  own SupervisorStrategyConfigurator
>> which I put into my Akka configuration file like this:
>> akka.actor.guardian-supervisor-strategy = "com....akka.
>> GuardianActorSupervisorStrategyConfigurator"
>> but it does not seem to have any effect
>>
>> This is the way I instantiate Akka in my rest controller:
>> public class MyRestController {
>>
>>     @Autowired
>>     private ActorSystem system;
>>
>>     @Autowired
>>     private AkkaSpringExtension extention;
>>
>>     private ActorRef persistenceActor;
>>
>>     @PostConstruct
>>     public void init()  {
>>         try {
>>             persistenceActor = system.actorOf(extention.
>> props("persistenceActor").withRouter( new FromConfig()),
>> "persistenceActor");
>>         } catch (Throwable e) {
>>             ...
>>         }
>>     }
>>
>> ....
>> }
>>
>> inside controller's method I call persistenceActor.tell(message, null);
>>
>> When my actor throws an exception the controller gets
>> AkkaTimeoutException instead of the exception thrown by the actor.
>>
>> I am wondering how can I force my actor to escalate the exception to the
>> rest controller? Putting escalate() into my 
>> GuardianActorSupervisorStrategyConfigurator
>> does not seem to be working
>>
>> Thanks,
>>
>> Mark
>>
>  --
> >>>>>>>>>> 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 http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Akka Team
Typesafe - The software stack for applications that scale
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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to