But,  if I implement supervisor,  I have to return restart, stop or
escalate right.
On 01-Jul-2014 7:40 PM, "√iktor Ҡlang" <viktor.kl...@gmail.com> wrote:

> If you don't want to restart the child you'll want to catch the exception
> and send another response to the sender.
>
>
> On Tue, Jul 1, 2014 at 4:05 PM, Yadukrishnan K <yadava...@gmail.com>
> wrote:
>
>> If any exception happened, say SQL Exception, I would like to return a
>> message, like "SOME_ERROR", so that the caller understand that some problem
>> occurred and show relevant message. Currently, when an exception occurs,
>> sender().tell() will not execute due to exception and Future Timeout
>> happens.
>>
>> Is my method not correct ?
>>
>>
>>
>>
>> On Tuesday, July 1, 2014 7:30:58 PM UTC+5:30, √ wrote:
>>
>>> send message where?
>>>
>>> http://doc.akka.io/docs/akka/2.3.4/scala/fault-tolerance.html
>>>
>>>
>>> On Tue, Jul 1, 2014 at 3:58 PM, Yadukrishnan K <yada...@gmail.com>
>>> wrote:
>>>
>>>> Using supervisor, I will be able to restart the failed actor, using
>>>> restart(), stop() etc right?
>>>> But Can I send message ?
>>>>
>>>> Can you please point me to a sample code for my case? I am really
>>>> getting confused with this.
>>>>
>>>>
>>>> On Tuesday, July 1, 2014 7:15:19 PM UTC+5:30, √ wrote:
>>>>
>>>>> Execute the SQL in a newly created child-actor and use supervision to
>>>>> deal with the exception?
>>>>>
>>>>>
>>>>> On Tue, Jul 1, 2014 at 3:43 PM, Yadukrishnan K <yada...@gmail.com>
>>>>> wrote:
>>>>>
>>>>>> Thanks for the quick reply.
>>>>>>
>>>>>> But how do I handle the Exceptions at a common place instead of
>>>>>> try-catch in each of the actors? (like SQL Exceptions )
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Tuesday, July 1, 2014 6:48:17 PM UTC+5:30, √ wrote:
>>>>>>
>>>>>>> I'd recommend against using Exceptions for validation. The
>>>>>>> non-existence of an Employee is a natural thing given an arbitrary 
>>>>>>> id—it is
>>>>>>> not exceptional.
>>>>>>>
>>>>>>>
>>>>>>> On Tue, Jul 1, 2014 at 3:08 PM, Yadukrishnan K <yada...@gmail.com>
>>>>>>> wrote:
>>>>>>>
>>>>>>>>  So do I have to do it in each of the actors ?
>>>>>>>> Is there any other way to handle it in a central place? For ex: in
>>>>>>>> Spring MVC, all the exceptions thrown from the controller can be 
>>>>>>>> handled
>>>>>>>> using @ControllerAdvice. Just looking if there is any similar thing.
>>>>>>>>
>>>>>>>> Not just this, I want to handle any SQLExceptions like Constraint
>>>>>>>> Violation and return a meaningful message to the caller. For that 
>>>>>>>> also, I
>>>>>>>> need to use try-catch in each of the actors and send corresponding 
>>>>>>>> message ?
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Tuesday, July 1, 2014 6:27:42 PM UTC+5:30, Yadukrishnan K wrote:
>>>>>>>>>
>>>>>>>>> I am a newbie to akka actor system. I am developing an application
>>>>>>>>> using Java, Spring, Hibernate and Akka.
>>>>>>>>> I am having problems with exception handling.
>>>>>>>>>
>>>>>>>>> My scenario is given below :
>>>>>>>>>
>>>>>>>>> REST API --> Spring MVC --> Service Layer (Actor) --> Hibernate
>>>>>>>>> Repository.
>>>>>>>>> Assume that I am trying to find an employee with id 1.
>>>>>>>>>
>>>>>>>>> Employee emp = HibernateRepository.findById(Employee.class, id);
>>>>>>>>> sender().tell(emp, self());
>>>>>>>>>
>>>>>>>>> If the employee with id=1 doesn't exist, the emp object will be
>>>>>>>>> NULL and sending NULL as message will throw InvalidMessageException.
>>>>>>>>> Is it possible to handle this exception and throw a custom
>>>>>>>>> Exception to the caller, say NoEntityFoundException? This help me to 
>>>>>>>>> check
>>>>>>>>> if the result I obtained is of Employee or CustomException. 
>>>>>>>>> Currently, I am
>>>>>>>>> getting Future timeout only.
>>>>>>>>>
>>>>>>>>> I have a BaseActor which extends akka.actor.AbstractActor. I also
>>>>>>>>> have another class, BaseModuleActor which extends BaseActor, as shown 
>>>>>>>>> below.
>>>>>>>>>
>>>>>>>>> public class BaseModuleActor extends BaseActor {
>>>>>>>>>
>>>>>>>>>     public  <T> ActorRef getActorRef(ActorSystem system,Class<T>
>>>>>>>>> clazz){
>>>>>>>>>         return system.actorOf(
>>>>>>>>>                 SpringExtension.SpringExtProvider.get(system).
>>>>>>>>> props(clazz));
>>>>>>>>>     }
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> All my actors are extending this actor, where I am doing like below
>>>>>>>>>
>>>>>>>>> @Override
>>>>>>>>>     public PartialFunction<Object, BoxedUnit> receive(){
>>>>>>>>>       return ReceiveBuilder
>>>>>>>>>               .match(Long.class, id-> getEmployeeById(id))
>>>>>>>>>               .build()
>>>>>>>>>               .orElse(matchAny());
>>>>>>>>>     }
>>>>>>>>> private void getEmployeeById(Long id){
>>>>>>>>>        Employee emp = HibernateRepository.findById(Employee.class,
>>>>>>>>> id);
>>>>>>>>>        sender().tell(emp, self());
>>>>>>>>>     }
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> But I am now stuck with handling the exceptions at a common place
>>>>>>>>> using the supervisor strategy.
>>>>>>>>> How can I catch the InvalidMessageException and resends some
>>>>>>>>> meaningful message to the caller. Is it possible?
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Regards,
>>>>>>>>> Yadu
>>>>>>>>>
>>>>>>>>  --
>>>>>>>> >>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>> >>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/c
>>>>>>>> urrent/additional/faq.html
>>>>>>>> >>>>>>>>>> Search the archives: https://groups.google.com/grou
>>>>>>>> p/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+...@googlegroups.com.
>>>>>>>> To post to this group, send email to akka...@googlegroups.com.
>>>>>>>>
>>>>>>>> Visit this group at http://groups.google.com/group/akka-user.
>>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Cheers,
>>>>>>> √
>>>>>>>
>>>>>>  --
>>>>>> >>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>> >>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/c
>>>>>> urrent/additional/faq.html
>>>>>> >>>>>>>>>> Search the archives: https://groups.google.com/grou
>>>>>> p/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+...@googlegroups.com.
>>>>>> To post to this group, send email to akka...@googlegroups.com.
>>>>>> Visit this group at http://groups.google.com/group/akka-user.
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Cheers,
>>>>> √
>>>>>
>>>>  --
>>>> >>>>>>>>>> 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+...@googlegroups.com.
>>>> To post to this group, send email to akka...@googlegroups.com.
>>>> Visit this group at http://groups.google.com/group/akka-user.
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>
>>>
>>> --
>>> Cheers,
>>> √
>>>
>>  --
>> >>>>>>>>>> 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.
>>
>
>
>
> --
> Cheers,
> √
>
> --
> >>>>>>>>>> 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 a topic in the
> Google Groups "Akka User List" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/akka-user/b2UOYVAXljw/unsubscribe.
> To unsubscribe from this group and all its topics, 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.
>

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