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

Reply via email to