Hi!

I have a streaming Akka HTTP client request that I would want to register 
an oncomplete callback on (in addition to the streaming which is working 
fine) which is called when the complete request-response is done. There 
doesn't seem to be anything in the Akka HTTP API directly (only toStrict 
method but I can't use that as I need to stream this) but I guess I can be 
looking at when the Akka stream is completed, right? If the stream is 
completed, is the full HTTP request-response completed then (all sockets 
closed and other resources released)?

I'm very new to Akka streams but how can I register an oncomplete callback 
on an Akka stream in Java?

This is roughly what I'm doing and I would want an oncomplete callback when 
it's all done streaming.

Future<HttpResponse> response_future = Http.get(system).singleRequest(
HttpRequest.create(url), am);
Future<Source<ByteString, ?>> source_future = response_future.map(new Mapper
<HttpResponse, Source<ByteString, ?>>() {
    public Source<ByteString, ?> apply(HttpResponse response) {
        return response.entity().getDataBytes();
    }
}, system.dispatcher());

source_future.flatMap(new Mapper<Source<ByteString, ?>, Future<String>>() {
    public Future<String> apply(Source<ByteString, ?> source) {
        PipedOutputStream output = new PipedOutputStream();
        InputStream input = new PipedInputStream(output);

        source.to(OutputStreamSink.create(new akka.japi.function.Creator<
OutputStream>() {
            public OutputStream create() {
                return output;
            }
        })).run(am);

        //doing stuff with input

        //how to register oncomplete callback?
        source.onComplete ???
    }
}, system.dispatcher());

Anyone have any good suggestions?

Thanks,
Johannes

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

Reply via email to