Hi

No its streams playing tricks on you
http://camel.apache.org/why-is-my-message-body-empty.html

So you get the body 2 times (at #2 and #3) and the 2nd time its empty.

On Wed, Mar 12, 2014 at 4:29 PM, Bengt Rodehav <[email protected]> wrote:
> I'm using Camel 2.12.1.
>
> For error handling purposes I need access to the original message but I'm
> having problems with that.
>
> In my error handler I do this:
>
>   Message originalMessage =
> theExchange.getUnitOfWork().getOriginalInMessage();
>   System.out.println(originalMessage); // 1
>   System.out.println("Body: " + originalMessage.getBody()); // 2
>   System.out.println("Body as string: " +
> originalMessage.getBody(String.class)); // 3
>
> The output at "1" is:
>
> TradeSet.xml
>
> The output at "2" is:
>
> Body:
> GenericFile[C:\dev\karaf\connect-sts\head\apache-karaf2.3.4\bin\..\..\..\common\data\interfaces\ts2so\TradeSet.xml]
>
> The output at "3" is:
>
> Body as string: null
>
> I can reproduce this problem with a simple route that just uses the file
> component. Something like this:
>
> from("file:in").process(new Processor() {
>   public void process(Exchange theExchange) {
>   Message originalMessage =
> theExchange.getUnitOfWork().getOriginalInMessage();
>   System.out.println(originalMessage); // 1
>   System.out.println("Body: " + originalMessage.getBody()); // 2
>   System.out.println("Body as string: " +
> originalMessage.getBody(String.class)); // 3
>   }
> });
>
>
> Thus it seems like I can access the original message but I can't get the
> actual body content - at least not as a string. In my case the file
> contains an xml document that I need to get hold of. Is this a known bug or
> have I misunderstood the purpose with the getOriginalMessage() method?
>
> /Bengt



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: [email protected]
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Make your Camel applications look hawt, try: http://hawt.io

Reply via email to