We maybe need to make the JavaDocs more explicit?
2008/5/20 James Strachan <[EMAIL PROTECTED]>:
> 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.
>
>
> 2008/5/20 jhcha <[EMAIL PROTECTED]>:
>>
>> 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");
>> }
>> }
>>
>> --
>> View this message in context:
>> http://www.nabble.com/what-is-the-difference-between-requestBodyAndHeader-and-sendBodyAndHeader-method---tp17335200s22882p17335200.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
>
>
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>
> Open Source Integration
> http://open.iona.com
>
--
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://open.iona.com