Hi,
I want an asynchronous http client, and I found the svn repository:
http://svn.apache.org/repos/asf/httpcomponents/httpasyncclient/
I want a notify when the request has response with a callback function, but the
AsyncHttpClient only has the API to do "awaitResponse ()" method to wait and
block until there is response.
I think the using of it may not be called an asynchronous http client.
The test case in example org.apache.http.examples.nio.client.
AsyncClientRequest is
----
...
HttpHost target = new HttpHost("www.google.ch", 80);
BasicHttpRequest request = new BasicHttpRequest("GET", "/");
HttpExchange[] httpx = new HttpExchange[10];
for (int i = 0; i < httpx.length; i++) {
httpx[i] = asynchttpclient.execute(target, request);
}
for (int i = 0; i < httpx.length; i++) {
HttpResponse response = httpx[i].awaitResponse(); // block here
if (response != null) {
System.out.println("Response: " + response.getStatusLine());
}
}
...
----
When I change the code to following, it blocks one by one and not the one I
want, because I don't know which one will have response quickly.
----
...
HttpHost target = new HttpHost("www.google.ch", 80);
BasicHttpRequest request = new BasicHttpRequest("GET", "/");
HttpExchange[] httpx = new HttpExchange[10];
for (int i = 0; i < httpx.length; i++) {
httpx[i] = asynchttpclient.execute(target, request);
HttpResponse response = httpx[i].awaitResponse(); // block here
if (response != null) {
System.out.println("Response: " + response.getStatusLine());
}
}
...
----
Any suggestion is welcome, thanks in advance.
Sincerely,
Micky
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]