Hello! Thanks for looking into this, but I believe we are OK, and in fact your problem is described at [1]. We should clearly put it to camel-http wiki page.
The problem is that if we release the connection just after we execute the method we no longer can read from the stream returned by http method execution. There are two different solutions to this problem. 1) read the stream just after receiving it inside endpoint itself or 2) accept the fact that we don't know when to close the stream and put this responsibility to the user. advantage of 1) is that we always release the connection (it is released when we close the stream or read it completely), but 2) could be better, because we don't have to put the response into some object that might be not needed at all (and it is backward compatible because it returns stream). I just took the second approach when I was working on it as in majority of cases we read our responses anyway ;) [1] http://svn.apache.org/repos/asf/activemq/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/MultiThreadedHttpGetTest.java Roman 2008/5/28 jhcha <[EMAIL PROTECTED]>: > > 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. > >
