I would think it is because the setbody is setting the body in the IN
exchange and the response you get is from the OUT exchange due to the
request/reply nature of your operation. It works similarly with RabbitMQ
where you have to set exchangePattern to InOut to get request/reply. If you
log the actual headers you will see the exchange values so you can compare.

On Wed, Sep 21, 2016 at 8:59 PM, sim085 [via Camel] <
ml-node+s465427n5787905...@n5.nabble.com> wrote:

> Hello, I am trying some Camel with Jetty examples. The problem I have is
> that after I do an http request to another site jetty no longer returns the
> set body.
>
> For example,
>
> [code]
>     from("jetty:http://localhost:8080";).setBody(constant("OK"));
> [/code]
>
> Returns "OK" when from the browser I call the above set URL. However if
> the following will not work.
>
> [code]
>     from("jetty:http://localhost:8080";)
>     .to("jetty:http://www.google.com"; +
>     "?bridgeEndpoint=true" +
>         "&throwExceptionOnFailure=false")
>     .setBody(constant("OK"));
> [/code]
>
> This returns the response from google (see attachment at end of message)
> and not "OK" even though after the call to google I am setting the body to
> "OK".
>
> What I find strange is this ...
>
> The following code prints in the console that the body is "OK" but the
> response returned to the browser is still the response got from google.
>
> [code]
>     from("jetty:http://localhost:8080";)
>     .to("jetty:http://www.google.com"; +
>     "?bridgeEndpoint=true" +
>         "&throwExceptionOnFailure=false")
>     .setBody(constant("OK"))
>     .log("THE BODY IS ${body}"); // This line prints "OK" in the console.
> [/code]
>
> After looking through the Jetty Camel documentation I saw an example which
> was overriding the body and that one works.
>
> [code]
>     from("jetty:http://localhost:8080";)
>     .to("jetty:http://www.google.com"; +
>     "?bridgeEndpoint=true" +
>         "&throwExceptionOnFailure=false")
>     .process(new Processor(){
>     public void process(Exchange e) throws Exception {
>     e.getOut().setBody("HELLO");
>     }
>     })
>     // .setBody(constant("OK")) // LINE 1
>     .log("THE BODY IS ${body}");
> [/code]
>
> The above without LINE 1 remarked returns "HELLO" in both browser and
> console and with LINE 1 not remarked it returns "OK" in both browser and
> console.
>
> So why does setBody work when e.getOut().setBody(...) is used but not if
> this is used without the processor?
>
>
>
>
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://camel.465427.n5.nabble.com/Why-is-the-set-body-not-
> being-returned-tp5787905.html
> To start a new topic under Camel - Users, email
> ml-node+s465427n465428...@n5.nabble.com
> To unsubscribe from Camel - Users, click here
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=465428&code=c291Y2lhbmNlLmVxZGFtLnJhc2h0aUBnbWFpbC5jb218NDY1NDI4fDE1MzI5MTE2NTY=>
> .
> NAML
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: 
http://camel.465427.n5.nabble.com/Why-is-the-set-body-not-being-returned-tp5787905p5787907.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to