Return-Path: Delivered-To: apmail-activemq-camel-user-archive@locus.apache.org Received: (qmail 31935 invoked from network); 20 May 2008 08:31:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 20 May 2008 08:31:47 -0000 Received: (qmail 36809 invoked by uid 500); 20 May 2008 08:31:48 -0000 Delivered-To: apmail-activemq-camel-user-archive@activemq.apache.org Received: (qmail 36704 invoked by uid 500); 20 May 2008 08:31:48 -0000 Mailing-List: contact camel-user-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: camel-user@activemq.apache.org Delivered-To: mailing list camel-user@activemq.apache.org Received: (qmail 36693 invoked by uid 99); 20 May 2008 08:31:48 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 May 2008 01:31:48 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=SPF_PASS,URIBL_BLACK X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of gert.vanthienen@skynet.be designates 195.238.6.178 as permitted sender) Received: from [195.238.6.178] (HELO mailrelay011.isp.belgacom.be) (195.238.6.178) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 May 2008 08:30:54 +0000 X-Belgacom-Dynamic: yes X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AuMBAJspMkhR8bur/2dsb2JhbAAIgxeqTQ Received: from 171.187-241-81.adsl-dyn.isp.belgacom.be (HELO [192.168.0.102]) ([81.241.187.171]) by relay.skynet.be with ESMTP; 20 May 2008 10:31:16 +0200 Message-ID: <48328C54.2030307@skynet.be> Date: Tue, 20 May 2008 10:31:16 +0200 From: Gert Vanthienen User-Agent: Thunderbird 2.0.0.14 (X11/20080505) MIME-Version: 1.0 To: camel-user@activemq.apache.org Subject: Re: what is the difference between requestBodyAndHeader and sendBodyAndHeader method ? References: <17335200.post@talk.nabble.com> In-Reply-To: <17335200.post@talk.nabble.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org J.H.Cha, The only difference I see when I look at the code, it the message ExchangePattern. requestBodyAndHeader() explicitly sets the pattern to InOut, while the sendBodyAndHeader() just leaves the default (InOnly). Not sure why this causes a problem in your case though, I would even think that InOut would be a more correct representation... I would guess that the InOut pattern causes the http: endpoint to wait on a reply from the jetty: endpoint, but I'm not sure why that doesn't happen. What version of Camel are you using? To determine what's going on here, could you try replacing your http/jetty endpoints with a direct:b or something? Regards, Gert jhcha wrote: > When I tested two methods requestBodyAndHeader and sendBodyAndHeader in my > test source, > I found the very curious result. > > sendBodyAndHeader returns ok, but requestBodyAndHeader does not return, and > hangs... > > two methods have the same(?) input parameters and very similar comments.. > (Is it different things, endpoint and endpointUri ? ) > > Object requestBodyAndHeader(String endpoint, Object body, String header, > Object headerValue) > Send the body to an endpoint returning any result output body > > Object sendBodyAndHeader(String endpointUri, Object body, String header, > Object headerValue) > Sends the body to an endpoint with a specified header and header > value > > Maybe I should not use requestBodyAndHeader with "direct" end point. > > but I need to know the accurate reason for that. > > Would you explain me what is the difference of the two methods, > and the correct usage case ? > > Thank you. > > J. H. Cha > > the below source is my test code. > ============================= > > > import org.apache.camel.CamelContext; > import org.apache.camel.CamelTemplate; > import org.apache.camel.Endpoint; > 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; > import org.apache.camel.util.ExchangeHelper; > import org.apache.log4j.Logger; > > public class JettyRequestTest extends Thread { > > private static final Logger logger = > Logger.getLogger(JettyRequestTest.class); > > private static int threads = 1; > > > public static void main(String[] args) throws Exception { > > for (int i = 0; i < threads; i++) { > JettyRequestTest client = new JettyRequestTest(); > client.start(); > } > } > > @Override > public void run() { > try { > testJettyConsumerEndpoint(); > } catch (Exception e) { > logger.fatal("testJmsSpeed fail", e); > } > } > > public void testJettyConsumerEndpoint() throws Exception { > try { > CamelContext ctx = new DefaultCamelContext(); > > RouteBuilder builder = new ServerRoutes(); > ctx.addRoutes(builder); > > ctx.start(); > > CamelTemplate template = new > CamelTemplate(ctx); > > String body = "world!"; > > Object result = template.sendBodyAndHeader("direct:start", body, > "Content-Type", "application/xml"); > Exchange exchange = new DefaultExchange(ctx); > String response = ExchangeHelper.convertToType(exchange, String.class, > result); > logger.info("response : [" + response + "]"); > > // the below line meet hang !!!! > template.requestBodyAndHeader("direct:start", body, "Content-Type", > "application/xml"); > > > ctx.stop(); > } catch (Throwable e) { > if (logger.isEnabledFor(org.apache.log4j.Level.ERROR)) { > logger.error("testJettyConsumerEndpoint()", 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"); > } > } > >