Hi,

Many thanks for your investigation and for the test. We will look into it asap.

Hadrian

On May 28, 2008, at 8:10 AM, jhcha wrote:


Dear Camel Developer

I has found the bug in camel-http component.

At first I posted the mail of the title, "what is the difference between requestBodyAndHeader and sendBodyAndHeader method ?" and some other mails.

I tried to know what happened in the camel for myself.
and I had found the hang at the third http request call after the second
http request call.

Namely, the third http request call always hanged in all camel http request
method (template.sendBody, template.requestBody ...)

So, I has found the camel http component source skipped the http connection
release call  documented at the http client threading docuemnt
http://hc.apache.org/httpclient-3.x/threading.html
http://hc.apache.org/httpclient-3.x/threading.html

that is why the third http request hangs.

The http client connection pool has the default connections 2.

Maybe
org.apache.camel.component.http.HttpPollingConsumer.java and
org.apache.camel.component.http.HttpProducer.java must be included http
client connection release method call after
httpClient.executeMethod(method);

I upload my patched source.

http://www.nabble.com/file/p17511201/HttpPollingConsumer.java
HttpPollingConsumer.java
and
http://www.nabble.com/file/p17511201/HttpProducer.java HttpProducer.java

Would you check the camel-http componet source and patch it.

The below source is my test source.
==================================================
import org.apache.camel.CamelContext;
import org.apache.camel.CamelTemplate;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.impl.DefaultExchange;

public class JettyRequestTest {

        public static void main(String[] args) throws Exception {

                JettyRequestTest client = new JettyRequestTest();
                client.testJettyRequest();
        }

        public void testJettyRequest() throws Exception {
                try {
                        CamelContext ctx = new DefaultCamelContext();

                        RouteBuilder builder = new ServerRoutes();
                        ctx.addRoutes(builder);

                        ctx.start();

                        CamelTemplate<DefaultExchange> template = new
CamelTemplate<DefaultExchange>(ctx);

                        String body = "<hello>world!</hello>";

                        template.requestBody("direct:start", body);
                        // ok
                        template.requestBody("direct:start", body);
                        // ok
                        template.requestBody("direct:start", body);
                        // --> hang

                        ctx.stop();
                } catch (Throwable e) {
                        e.printStackTrace();
                }
        }
}

class ServerRoutes extends RouteBuilder {

        @Override
        public void configure() throws Exception {
                // 본문 수신 및 응답
                Processor proc = new Processor() {
                        public void process(Exchange exchange) throws Exception 
{
                                String request = 
exchange.getIn().getBody(String.class);
                                exchange.getOut(true).setBody(request + " >> 
processed");
                        }
                };

                from("jetty:http://localhost:8080/hello";).process(proc);
                from("direct:start").to("http://localhost:8080/hello";);

        }
}

==================================================
Thanks a lot

J. H. Cha




--
View this message in context: 
http://www.nabble.com/Bug-at-the-camel-http-component-tp17511201s22882p17511201.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Reply via email to