camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gert Vanthienen <gert.vanthie...@skynet.be>
Subject Re: what is the difference between requestBodyAndHeader and sendBodyAndHeader method ?
Date Tue, 20 May 2008 10:23:22 GMT
J.H.Cha,

It's probably best to raise a JIRA for this and describe what works and 
what doesn't in there.  We definitely have to look into this further...

Gert

jhcha wrote:
> I found sendBody or requestBody methods also have the same problem.
>  
> when sendBody or requestBody method was called fastly several times,
> and the return object (result) was referenced, 
> then program was hanged. 
>
> ====================================
> 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>";
>
> 			Object result;
>
> 			result = template.sendBody("direct:start", body);
> 			result = template.sendBody("direct:start", body);
> 			result = template.sendBody("direct:start", body);
> 			// --> hang
>
> //			template.sendBody("direct:start", body);
> //			template.sendBody("direct:start", body);
> //			template.sendBody("direct:start", body);
> 			// --> ok
>
> //			result = template.requestBody("direct:start", body);
> //			result = template.requestBody("direct:start", body);
> //			result = template.requestBody("direct:start", body);
> 			// --> hang
>
> //			template.requestBody("direct:start", body);
> //			template.requestBody("direct:start", body);
> //			template.requestBody("direct:start", body);
> 			// --> sometimes 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");
> 	}
> }
>
> Could you check the reason? 
>
>
> The idea behind request*() is that they implement InOut semantics
> (request-reply) so they block waiting for response - whereas send*()
> methods are InOnly (one-way) methods. 
>
> The above exlpain is very helpfull to me. 
> but It was confusing that send method also can receive response. 
> that point makes me confused. 
>
> I hope you document two methods and others a little bit in detail. 
>
> Thanks a lot
>
> J. H. Cha
>
>
>
> Maybe the http/jetty components need to be fixed to work correctly
> with InOut operations?
>
>
>   


Mime
View raw message