hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jose Dillet <jose.dil...@gmail.com>
Subject Sharing the connection manager amongst client instances
Date Mon, 07 Apr 2014 13:06:35 GMT
Hi,

In our application we have been sharing the connection manager amongst
HttpClient instances successfully. Due to our desing we want to have more
than one HttpClient
instance, but sharing the same underlying resources. This has been working
for HttpClient instances (see attached code SharedHttpClient for a sample
with httpclient-4.2.3,
and SharedHttpClient2 for a sample using httpclient-4.3.3

When using async client, things were still working with
httpasyncclient-4.0-beta3 (see SharedHttpAsyncClient) but does not work
anymore with httpasyncclient-4.0.1 (see
SharedHttpAsyncClient2)

When I run SharedHttpAsyncClient2 I got this stack trace:

15:23:10 ERROR - I/O reactor terminated abnormally
java.lang.IllegalStateException: Illegal state ACTIVE
    at org.apache.http.util.Asserts.check(Asserts.java:40)
    at
org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:313)
    at
org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.execute(PoolingNHttpClientConnectionManager.java:189)
    at
org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase.doExecute(CloseableHttpAsyncClientBase.java:67)
    at
org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase.access$000(CloseableHttpAsyncClientBase.java:38)
    at
org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase$1.run(CloseableHttpAsyncClientBase.java:57)
    at java.lang.Thread.run(Thread.java:744)
GET http://www.apache.org/ HTTP/1.1->HTTP/1.1 200 OK
Exception in thread "main" java.lang.IllegalStateException: Request cannot
be executed; I/O reactor status: STOPPED
    at org.apache.http.util.Asserts.check(Asserts.java:40)
    at
org.apache.http.impl.nio.client.InternalHttpAsyncClient.execute(InternalHttpAsyncClient.java:112)
    at
org.apache.http.impl.nio.client.CloseableHttpAsyncClient.execute(CloseableHttpAsyncClient.java:72)
    at
org.apache.http.impl.nio.client.CloseableHttpAsyncClient.execute(CloseableHttpAsyncClient.java:102)
    at
org.apache.http.impl.nio.client.CloseableHttpAsyncClient.execute(CloseableHttpAsyncClient.java:87)
    at
org.apache.http.examples.nio.client.SharedHttpAsyncClient2.makeRequest(SharedHttpAsyncClient2.java:51)
    at
org.apache.http.examples.nio.client.SharedHttpAsyncClient2.main(SharedHttpAsyncClient2.java:40)

The problem seems that now client1.isRunning() returns the status of the
current CloseableHttpAsyncClient instance, while previously it returned the
status of the
underlying connection manager, so client2.start() was skipped.

So in summary, is sharing the connection manager amongst client instances
supported?

Thanks,
Jose

Mime
View raw message