I am trying to to create http client, using akka http. I have already founded interesting solution which I want to use: How to properly call Akka HTTP client for multiple (10k - 100k) requests? But I can't find any way to get exeptions from this constraction
Source.from(() -> httpRequests.iterator())
.via(connectionFlow)
.runForeach((HttpResponse response) -> onComplete.accept(response), materializer);
of cource I can log them, but I need some custom exceptions processing whith try-catch construction.
Probably I need to use recoverWith method, but I use Java not Scala, and I am not sure hov to use this method correctly. This signature is
recoverWith[T >: Out](pf: PartialFunction[Throwable, _ <: Graph[SourceShape[T], NotUsed]]): Source[T, Mat @uncheckedVariance]
and I am not sure which types and which Graph implementation use here.
For single request I use this construction:
CompletionStage<HttpResponse> future = Http.get(actorSystem).singleRequest(httpRequest, materializer);
future.whenComplete((HttpResponse response, Throwable failure) -> onComplete.accept(failure, response));
Please help me if there is some way to process many requests with exeptions handling using akka-http.