You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by samslara <sa...@yahoo.com> on 2011/09/22 02:51:27 UTC
Message.copy() not exactly a copy
Hi,
I currently have a camel route that makes use of HttpComponent. After
calling a service and getting a String back in the body I tried to do a
Message.copy(), with the Message being from exchange.getIn(). The original
Message body is of type String but the new Message body isn't of type
String, rather it's of type
org.apache.camel.converter.stream.CachedOutputStream$WrappedInputStream.
Why doesn't it keep the body a String?
--
View this message in context: http://camel.465427.n5.nabble.com/Message-copy-not-exactly-a-copy-tp4828478p4828478.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Message.copy() not exactly a copy
Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Sep 23, 2011 at 12:51 AM, samslara <sa...@yahoo.com> wrote:
> Ah you're right. But when I do the following at some point after invoking a
> service with HttpComponent:
>
> exchange.getIn().getBody(String.class);
>
> it returns a String ok, which is the response of the service. But if I
> instead do:
>
> exchange.getIn().copy().getBody(String.class);
>
> this returns null. Why is that?
>
The source stream seems not being able to be copied.
> --
> View this message in context: http://camel.465427.n5.nabble.com/Message-copy-not-exactly-a-copy-tp4828478p4831804.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/
Re: Message.copy() not exactly a copy
Posted by samslara <sa...@yahoo.com>.
Ah you're right. But when I do the following at some point after invoking a
service with HttpComponent:
exchange.getIn().getBody(String.class);
it returns a String ok, which is the response of the service. But if I
instead do:
exchange.getIn().copy().getBody(String.class);
this returns null. Why is that?
--
View this message in context: http://camel.465427.n5.nabble.com/Message-copy-not-exactly-a-copy-tp4828478p4831804.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Message.copy() not exactly a copy
Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Sep 22, 2011 at 2:51 AM, samslara <sa...@yahoo.com> wrote:
> Hi,
> I currently have a camel route that makes use of HttpComponent. After
> calling a service and getting a String back in the body I tried to do a
> Message.copy(), with the Message being from exchange.getIn(). The original
> Message body is of type String but the new Message body isn't of type
> String, rather it's of type
> org.apache.camel.converter.stream.CachedOutputStream$WrappedInputStream.
> Why doesn't it keep the body a String?
>
You may been fooled that the original body is a String.
Http HTTP component uses streams, and hence the message body is an InputStream.
> --
> View this message in context: http://camel.465427.n5.nabble.com/Message-copy-not-exactly-a-copy-tp4828478p4828478.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/