camel-http4
. 基本上,在上下文启动时,该路由每5分钟向外部服务器发出一个http请求。这工作非常好。
在某个时候,我想重新启动camel上下文(使用JMX),所以我只需要:
if (camelContext.getStatus().isStoppable()) {
camelContext.stop();
}
后来:
if (camelContext.getStatus().isStarttable()) {
camelContext.start();
}
两个操作似乎都成功了,日志确认了实际的停止和启动。但是当发出第一个http请求时,我得到以下错误:
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]
连接池似乎处于无效状态。
如何在启动上下文时强制重新创建池?
版本:
骆驼-http4 2.17
apache httpclient 4.5.2版
我已经看到一些帖子说连接管理器必须通过使用HttpClientConfigurer(这更像是一个解决方法)来共享。
我定义并注入了自己的客户端配置程序,但它不起作用:
public class MyHttpClientConfigurer implements HttpClientConfigurer {
@Override
public void configureHttpClient(HttpClientBuilder httpClientBuilder) {
httpClientBuilder.setConnectionManagerShared(true);
}
}