我使用Camel作为编排引擎。
clients sends HTTP request <-> CAMEL code <---- HTTP Req----- > external
server(s)
我正在使用HTTP4组件(使用默认设置)来发出HTTP请求 到外部服务器。我有很多http后端。
现在我们对后端进行http调用的方式如下: -
// 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);
}
});
我的查询是: -
HTTP4
是否使用了一些http连接
在打电话给外部服务器时汇集?blueprint.xml
? 我正在使用Camel 2.16.1
,应用程序部署在Karaf 3.0.5
中。
答案 0 :(得分:4)
http4
组件使用Apache HttpClient,它支持使用HttpClientConnectionManager
进行池化。
默认情况下,camel使用的PoolingHttpClientConnectionManager
使用属性connectionsPerRoute
和maxTotalConnections
进行配置。
如果您想要对此clientConnectionManager有更多控制权,可以提供自己的org.apache.http.conn.HttpClientConnectionManager
实现