在Camel中的Http连接池

时间:2016-03-12 16:47:33

标签: apache-camel

我使用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);
        }
    });

我的查询是: -

  1. 默认设置中的HTTP4是否使用了一些http连接 在打电话给外部服务器时汇集?
  2. 如果是,有没有办法可以配置连接池 blueprint.xml
  3. 我正在使用Camel 2.16.1,应用程序部署在Karaf 3.0.5中。

1 个答案:

答案 0 :(得分:4)

http4组件使用Apache HttpClient,它支持使用HttpClientConnectionManager进行池化。

默认情况下,camel使用的PoolingHttpClientConnectionManager使用属性connectionsPerRoutemaxTotalConnections进行配置。

如果您想要对此clientConnectionManager有更多控制权,可以提供自己的org.apache.http.conn.HttpClientConnectionManager实现

请参阅HttpClient connection manager