Rafal,

Thanks for the clarification. The pattern you are describing works very 
well if your entire application is Akka based. In that case there is no 
need to externalize the exceptions, everything is handled internally. Rest 
controllers are a different matter. My thought was that different 
controllers will spawn different actor hierarchies, some simple (as in 
example above where a single actor is responsible for handing the 
persistence) some very complicated with the deep actor's tree. I wanted to 
be able to handle actor's exception's in simple cases, but now I realize 
that Akk won't let me do it. I guess I will have to rethink my strategy.

Thanks,

Mark

On Tuesday, October 14, 2014 5:25:29 PM UTC-4, Rafał Krzewski 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.

Reply via email to