I've actually done a concurrent HTTP request executor for HttpBuilder (the Groovy HttpClient wrapper): http://groovy.codehaus.org/modules/http-builder/doc/async.html
I don't want you to get sidetracked by the Groovy details, but you could do something like this: Future result = RequestBuilder.build(uri, GET_METHOD).exec( new ResponseCallback() { public Object onResponse(FluentResponse resp) { // do something asynchronous with the response here }); while ( ! result.isDone() ) { // wait for response and do something synchronously when it's done. } Note that java.util.concurrent.Future is generic, so you should probably make ResponseCallback generic too e.g. Future<JSONObject> result = RequestBuilder.build(uri, GET_METHOD).exec( new ResponseCallback<JSONObject>() { public JSONObject onResponse(FluentResponse resp) { // do something asynchronously with the response here }); JSONObject responseBody = result.get(10000,TimeUnit.SECONDS) I used a ThreadPoolExecutor in my impl, see: http://groovy.codehaus.org/modules/http-builder/xref/groovyx/net/http/AsyncHTTPBuilder.html#154 and if you're lucky, all of your other FluentHC code is already threadsafe, so you can just call your super.exec from the threadPool like so: http://groovy.codehaus.org/modules/http-builder/xref/groovyx/net/http/AsyncHTTPBuilder.html#128 - Thom On Sat, Jul 16, 2011 at 2:47 PM, Oleg Kalnichevski <ol...@apache.org> wrote: > On Mon, 2011-07-11 at 16:48 +0300, Xu, Lilu wrote: > > Hi Oleg, > > > > I've accomplished the parts of proxy [1], authentication [2], connection > > manager [3] and connection manager builder [4]. Some "to me not so > > important" methods are ignored this time. > > The progress of the development can still be observed in google doc [4]. > I > > think it should be quite possible to have all essential features listed > in > > the progress table by the end of July. > > > > Comments and suggestions (both the codes and the progress) are welcomed! > > > > [1] http://code.google.com/p/fluent-hc/wiki/ProxyConfiguration > > [2] http://code.google.com/p/fluent-hc/wiki/HttpAuthentication > > [3] http://code.google.com/p/fluent-hc/wiki/FluentClientConnManager > > [4] http://code.google.com/p/fluent-hc/wiki/ConnManagerBuilder > > > Hi Lilu > > Truth to be told I am not sure I like ConnManagerBuilder / > FluentClientConnManager that much. I always felt that a FluentExecutor > encapsulating DefaultHttpClient and ThreadSafeClientConnManager would > have probably been a more elegant solution. This would also enable us to > decouple HttpClient and request execution related methods from > FluentRequest. > > Just a thought. > > > [5] > > > https://spreadsheets.google.com/spreadsheet/ccc?key=0AmpiN3H1I3fndFBaOHpoSzI4MHlMS3RaSVg3ZEFrUkE&hl=en_US&authkey=CJTnkIoG > > > > I think we have the almost essential bits already in place. From all > missing features listed in the spreadsheet only multi-threaded request > execution is really a must in my opinion. I would very much rather > prefer that you concentrated on polishing features that are already > there instead of adding more. > > Please look into multi-threaded request execution as the step. As soon > as it is done we should start making plans for an official ALPHA release > of FluentHC. > > Oleg > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org > For additional commands, e-mail: dev-h...@hc.apache.org > >