Maybe the http/jetty components need to be fixed to work correctly
with InOut operations?
2008/5/20 jhcha <[EMAIL PROTECTED]>:
>
> Dear Gert Vanthienen.
>
> Thank you for replying so quickly!
>
> I tested your sugestion, I modified the blow part of my test source.
>
> // from("direct:http://localhost:8080/hello").process(proc);
> // from("direct:start").to("http://localhost:8080/hello");
>
> from("direct:test").process(proc);
> from("direct:start").to("direct:test");
>
> The result was ok! hanging did not happend !!!
>
> so..
>
> then maybe that http endpoint and the jetty end point have some problems but
> I don't know..
>
> I use the camel 1.3.0 in eclipse 3.3.2, jdk 1.5.0_14, and windows xp sp3.
>
>
> I used the below jars and camel-core, camel-jetty imported from camel 1.3.0
> source with "maven eclipse:eclipse" in my eclipse.
>
> Coud you find the reason ?
>
> Thanks a lot.
>
> J. H. Cha
>
> ==============================================================================
> <?xml version="1.0" encoding="UTF-8"?>
> <classpath>
> <classpathentry kind="con"
> path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
> <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/log4j"/>
> <classpathentry kind="src" path="src"/>
> <classpathentry combineaccessrules="false" kind="src"
> path="/camel-core"/>
> <classpathentry kind="lib"
> path="D:/tools/camel/apache-camel-1.3.0/lib/camel-xmlbeans-1.3.0.jar"/>
> <classpathentry kind="var"
> path="M2_REPO/commons-logging/commons-logging/1.0.4/commons-logging-1.0.4.jar"/>
> <classpathentry kind="var"
> path="M2_REPO/javax/activation/activation/1.1/activation-1.1.jar"
> sourcepath="M2_REPO/javax/activation/activation/1.1/activation-1.1-sources.jar"/>
> <classpathentry kind="var"
> path="M2_REPO/org/apache/geronimo/specs/geronimo-jms_1.1_spec/1.1/geronimo-jms_1.1_spec-1.1.jar"/>
> <classpathentry kind="var"
> path="M2_REPO/org/apache/camel/camel-spring/1.3.0/camel-spring-1.3.0.jar"/>
> <classpathentry kind="var"
> path="M2_REPO/org/apache/geronimo/specs/geronimo-j2ee-management_1.0_spec/1.1/geronimo-j2ee-management_1.0_spec-1.1.jar"/>
> <classpathentry kind="var"
> path="M2_REPO/org/springframework/spring/2.5.1/spring-2.5.1.jar"/>
> <classpathentry kind="var"
> path="M2_REPO/com/sun/xml/bind/jaxb-impl/2.1.3/jaxb-impl-2.1.3.jar"/>
> <classpathentry kind="var"
> path="M2_REPO/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.jar"/>
> <classpathentry kind="var"
> path="M2_REPO/commons-logging/commons-logging-api/1.0.4/commons-logging-api-1.0.4.jar"/>
> <classpathentry kind="var"
> path="M2_REPO/javax/xml/bind/jaxb-api/2.1/jaxb-api-2.1.jar"/>
> <classpathentry kind="lib"
> path="D:/tools/commons/commons-pool-1.3/commons-pool-1.3.jar"/>
> <classpathentry kind="lib" path="lib/jta.jar"/>
> <classpathentry kind="lib"
> path="D:/tools/jetty/jetty-6.1.5/lib/servlet-api-2.5-6.1.5.jar"/>
> <classpathentry combineaccessrules="false" kind="src"
> path="/camel-jetty"/>
> <classpathentry kind="lib"
> path="D:/tools/camel/apache-camel-1.3.0/lib/camel-http-1.3.0.jar"/>
> <classpathentry kind="lib" path="C:/Documents and
> Settings/cha/.m2/repository/commons-httpclient/commons-httpclient/3.1/commons-httpclient-3.1.jar"/>
> <classpathentry kind="output" path="bin"/>
> </classpath>
>
>
>
>
>
>
>
> Gert Vanthienen wrote:
>>
>> 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<DefaultExchange> template = new
>>> CamelTemplate<DefaultExchange>(ctx);
>>>
>>> String body = "<hello>world!</hello>";
>>>
>>> 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");
>>> }
>>> }
>>>
>>>
>>
>>
>>
>> -----
>> ---
>> Gert Vanthienen
>> http://www.anova.be
>>
>
> --
> View this message in context:
> http://www.nabble.com/what-is-the-difference-between-requestBodyAndHeader-and-sendBodyAndHeader-method---tp17335200s22882p17336225.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
--
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://open.iona.com