简体   繁体   English

没有连接缓存的Apache Camel HTTP路由

[英]Apache Camel http routing with no connection caching

I need Apache Camel to stop caching information on HTTP connections because it prevents my F5 load balancer from working properly. 我需要Apache Camel来停止在HTTP连接上缓存信息,因为这会阻止F5负载均衡器正常工作。

This is the route definition: 这是路线定义:

from("direct:source").to("http://www.destination.com?bridgeEndpoint=true&throwExceptionOnFailure=false");

The situation is that I have 2 processes running Camel routes and consuming traffic. 情况是,我有2个进程在运行Camel路由并消耗流量。 Then these 2 processes forward all the traffic to load balancer address, which should then balance the traffic uniformly between 4 servers. 然后,这2个进程将所有流量转发到负载均衡器地址,然后该负载均衡器地址应在4个服务器之间统一均衡流量。 Currently, Camel overcomes load balancer and directs all the traffic directly to 2 out of 4 servers. 当前,Camel克服了负载平衡器的问题,并将所有流量直接定向到4台服务器中的2台。 The other 2 servers remain idle. 其他2台服务器保持空闲状态。 I'm sure that this is not a load balancer issue. 我确定这不是负载平衡器问题。

Have you tried setting a the http header 您是否尝试过设置http标头

Connection: Close

To tell the http client to close the connection. 告诉http客户端关闭连接。

You can set it from Camel also 您也可以从骆驼设置

from aaa
   .setHeader("Connection", constant("Close"))
   .to bbb

I've been trying various configurations. 我一直在尝试各种配置。 What I found which solves the issue is the following: 我发现解决该问题的方法如下:

<bean id="http" class="org.apache.camel.component.http.HttpComponent">
    <property name="camelContext" ref="camel"/>
    <property name="httpConnectionManager" ref="httpConnectionManager"/>
</bean>

<bean id="httpConnectionManager" class="org.apache.commons.httpclient.SimpleHttpConnectionManager">
    <constructor-arg index="0" value="true"/>
</bean>

SimpleHttpConnectionManager has a constructor with a boolean "alwasyClose", which does the job. SimpleHttpConnectionManager具有一个带有布尔值“ alwasyClose”的构造函数,该函数可以完成此工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM