Yeah, it's actually fairly uncommon to want a Future inside your Actor --
this is only one of the many reasons why.  I've found that cases like this
tend to be either:

a)  You're doing something long-running, and then want to throw an
exception in response to the results (in which case, the Future should
probably send a message back to the Actor, and that's where you do this
validation, in its normal receive processing); or
b)  You want to throw an exception in the middle of some long-running
computation (in which case, that computation may well want to be split off
into its own Actor, which gets managed with normal supervision).


On Mon, Dec 30, 2013 at 11:47 PM, Miguel Angel Iglesias <[email protected]>wrote:

> Can you elaborate in the use case where you want to use a future there? Is
> probable that you don't really need to use it at all...
>
>
> On Mon, Dec 30, 2013 at 5:49 PM, Lucas Batistussi <
> [email protected]> wrote:
>
>> What I have to do to still support fault tolerance when using Future as
>> shown in code below?
>>
>> ...
>> override def receive = {
>>
>>    case email: Email => Future {
>>
>>       // Suppose here I got an exception. Without "Future", supervisor 
>> strategy
>>       // works well restarting the actor
>>       throw new MailException("ops!")
>>
>>    }
>> }
>>
>> Supervisor Strategy:
>>
>> ...
>> withSupervisorStrategy(
>>    OneForOneStrategy(
>>
>>  // Max number of retries
>>  maxNrOfRetries = retries,
>>  // Time Window
>>  withinTimeRange = timeRange) {
>>
>>  case ex: MailException => {
>>    Restart
>>  }
>> }))
>>
>>  --
>> >>>>>>>>>> Read the docs: http://akka.io/docs/
>> >>>>>>>>>> Check the FAQ: http://akka.io/faq/
>> >>>>>>>>>> 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 http://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>
>
> --
> Good hunting!
>
> --
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ: http://akka.io/faq/
> >>>>>>>>>> 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 http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: http://akka.io/faq/
>>>>>>>>>>      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 http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to