Thanks a lot for clarifying!
I missed the part that onComplete stops the chaining which when thinking 
about makes sense.
And indeed recover is all I need if I want to stick to the chaining  


Am Montag, 24. August 2015 14:28:46 UTC+2 schrieb Johan Andrén:
>
> Hi John,
>
> I think the Akka docs pretty much covers all of it actually, and was 
> written with a Java hat on, so it should be much easier for you as a Java 
> dev to read those than to look at the Scala-docs.
>
> You basically have two options, and both are covered in the docs:
>
> 1. side effecting using onComplete or onFailure. Note that these cannot 
> be chained so once you called either of these you get a Unit back (like 
> void in Java) so you cannot chain them in the same statement. Of course you 
> can capture your Future in a variable and call both onSuccess and 
> onFailure on that with separate statements. onComplete will get called 
> with both successful results and failures while onFailure only gets 
> called with failures.
>
> Examples for this in the docs is under "Callbacks": 
> http://doc.akka.io/docs/akka/2.3.12/java/futures.html#Callbacks
>
>
> 2. chaining transformations: if you know that you can solve the problem 
> with the exception, and transform it into a successful result, a default 
> for example, you can use recover and recoverWith as described here.
> http://doc.akka.io/docs/akka/2.3.12/java/futures.html#Exceptions
>
> Hope this helps!
> --
> Johan Andrén
> Typesafe -  Reactive apps on the JVM
> Twitter: @apnylle
>
>
> On Monday, August 24, 2015 at 10:22:40 AM UTC+2, [email protected] wrote:
>>
>> Hi,
>> For example I'm using:
>>
>> scala.concurrent.Future<HttpResponse> responseFuture = 
>> Http.get(system).singleRequest(request, materializer);
>>
>>
>> and then 
>>
>>
>> Future<HttpResponse>  newFuture  = responseFuture.flatMap(new 
>> Mapper<HttpResponse, Future<HttpResponse>>() {...}
>>
>> If I want to handle the StreamTcpException should I register a OnComplete 
>> Handler on responseFuture or on newFuture? 
>>
>>
>> As A general Question where can I get more infos about futures in akka 
>> (java) besides
>>
>> http://doc.akka.io/docs/akka/2.3.12/java/futures.html
>>
>> Should I try as a java programmer read the scala docs, articles?
>>
>>
>>

-- 
>>>>>>>>>>      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 http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to