简体   繁体   中英

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.

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. Then these 2 processes forward all the traffic to load balancer address, which should then balance the traffic uniformly between 4 servers. Currently, Camel overcomes load balancer and directs all the traffic directly to 2 out of 4 servers. The other 2 servers remain idle. I'm sure that this is not a load balancer issue.

Have you tried setting a the http header

Connection: Close

To tell the http client to close the connection.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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