I have defined a whole camel context with routes using the component camel-http4. Basically, upon context startup, this route issues every 5 minuets an http request towards an external server. This works just perfect.
At some point I want to restart the camel context (using JMX), so I just do:
if (camelContext.getStatus().isStoppable()) {
camelContext.stop();
}
And later:
if (camelContext.getStatus().isStarttable()) {
camelContext.start();
}
Both operations appear to succeed, logs confirm actual stop and start. But when the first http request is issued, I get the following error:
java.lang.IllegalStateException: Connection pool shut down
at org.apache.http.util.Asserts.check(Asserts.java:34)[org.apache.httpcomponents:httpcore-nio:4.4.4 org.apache.httpcomponents:httpcore-osgi:4.4.4 org.apache.httpcomponents:httpcore:4.4.4]
at org.apache.http.pool.AbstractConnPool.lease(AbstractConnPool.java:184)[org.apache.httpcomponents:httpcore-nio:4.4.4 org.apache.httpcomponents:httpcore-osgi:4.4.4 org.apache.httpcomponents:httpcore:4.4.4]
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.requestConnection(PoolingHttpClientConnectionManager.java:251)[commons-codec:commons-codec:1.9 org.apache.httpcomponents:fluent-hc:4.5.2 org.apache.httpcomponents:httpclient-cache:4.5.2 org.apache.httpcomponents:httpclient-osgi:4.5.2 org.apache.httpcomponents:httpclient:4.5.2 org.apache.httpcomponents:httpmime:4.5.2]
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:175)[commons-codec:commons-codec:1.9 org.apache.httpcomponents:fluent-hc:4.5.2 org.apache.httpcomponents:httpclient-cache:4.5.2 org.apache.httpcomponents:httpclient-osgi:4.5.2 org.apache.httpcomponents:httpclient:4.5.2 org.apache.httpcomponents:httpmime:4.5.2]
It looks like the connection pool is in an invalid state. How can I force the pool re-creation when starting context ? Is there other way to avoid this error ?
Versions: camel-http4 2.17 apache httpclient 4.5.2
I saw already some posts saying the connection manager has to be shared by using (it's more a workaround) HttpClientConfigurer. I define and inject my own client configurer, it does not work:
public class MyHttpClientConfigurer implements HttpClientConfigurer {
@Override
public void configureHttpClient(HttpClientBuilder httpClientBuilder) {
httpClientBuilder.setConnectionManagerShared(true);
}
}