Apache camel Camel中的Http连接池
我使用Camel作为编排引擎Apache camel Camel中的Http连接池,apache-camel,Apache Camel,我使用Camel作为编排引擎 clients sends HTTP request <-> CAMEL code <---- HTTP Req----- > external server(s) 我的问题是: 默认设置中的HTTP4camel是否使用一些http连接 在调用外部服务器时使用池 如果是,有没有办法从配置连接池 blueprint.xml 我使用的是Camel 2.16.1,应用程序部署在Karaf 3.0.5中 http4组件使用ApacheHttpCli
clients sends HTTP request <-> CAMEL code <---- HTTP Req----- > external
server(s)
我的问题是:
HTTP4
camel是否使用一些http连接
在调用外部服务器时使用池blueprint.xml
李>
我使用的是
Camel 2.16.1
,应用程序部署在Karaf 3.0.5
中 http4组件使用ApacheHttpClient,它支持使用HttpClientConnectionManager进行池化
默认情况下,camel使用一个poolighttpclientconnectionmanager
,该管理器配置了属性connectionsproute
和maxTotalConnections
如果您想更多地控制这个clientConnectionManager,可以提供自己的org.apache.http.conn.HttpClientConnectionManager的实现
请参见,因为connectionsPerRoute
和maxTotalConnections
具有默认值20和200。你能告诉我两者的区别吗?假设我有3个http后端A
,B
&C
。那么每个连接池最多有20个连接,总计60个?如果是,那么如果我有200多个http后端呢?您应该查看Apache HttpClient文档maxTotalConnections
是池管理的连接总数。在connectionsPerRoute
中,路由与camel无关,而是与作为“目的地”(主机+端口+代理/隧道)的HttpRoute
相关。所以你是对的:哪3个“目的地”,默认情况下最多有60个打开的连接。当然,您可以更改此默认配置
// The producer is created during app initialisation. This is actually done
via blueprint.xml
ProducerTemplate producer = camelContext.createProducerTemplate();
// Whenever I need to make a http call I am executing the below code with
URL set as something like:- "http4://order-api:8099/orders/v1/ordersearch/"
Exchange exchange = producer.request(URL, new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
log.info("Executing the HTTP request : URL - " + URL + " Headers -
" + headers + " Body : " + body);
exchange.getIn().setHeaders(headers);
exchange.getIn().setBody(body);
}
});