骆驼中的Http连接池

tuk*_*tuk 3 apache-camel

我正在使用骆驼作为业务流程引擎。

clients sends HTTP request <-> CAMEL code <---- HTTP Req----- > external
server(s)
Run Code Online (Sandbox Code Playgroud)

我正在使用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);
        }
    });
Run Code Online (Sandbox Code Playgroud)

我正在查询的是:

  1. HTTP4在默认设置中,骆驼在调用外部服务器时是否使用一些http连接池?
  2. 如果是,有没有办法我可以配置连接池 blueprint.xml

我正在使用,Camel 2.16.1并且该应用程序已部署在中Karaf 3.0.5

Jér*_*e B 5

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

默认情况下,骆驼使用PoolingHttpClientConnectionManager配置了属性connectionsPerRoute和的maxTotalConnections

如果您想进一步控制此clientConnectionManager,则可以提供自己的实现 org.apache.http.conn.HttpClientConnectionManager

请参阅HttpClient连接管理器