Here is an example of code that work as I aspected.:-(
Here is an example of code that works as I wanted.
I fail to get the exception using setHeader("exception",
header("CamelCauseException")).
Can you provide a piece of code?
When should we use exchange.getIn().setBody() or
exchange.getOut().setBody()?
public class ExceptionTest extends ContextTestSupport
{
MockEndpoint endEndpoint;
@Override
protected void setUp() throws Exception
{
super.setUp();
endEndpoint = getMockEndpoint("mock:end");
}
@Override
protected RouteBuilder createRouteBuilder() throws Exception
{
return new RouteBuilder()
{
@Override
public void configure() throws Exception
{
from("direct:start").process
( new Processor()
{
public void process(Exchange
exchange) throws Exception
{
try
{
throw new
Exception("Test exception");
}
catch (Exception e)
{
StringWriter
stringWritter = new StringWriter();
PrintWriter
printWritter = new PrintWriter(stringWritter, true);
e.printStackTrace(printWritter);
printWritter.flush();
stringWritter.flush();
exchange.getIn().setBody(stringWritter.toString());
template.send("activemq:queue:Exception", exchange);
}
}
}
);
}
};
}
public void testException() throws InterruptedException
{
endEndpoint.expectedMessageCount(1);
template.sendBody("direct:start", "test Exception");
MockEndpoint.assertIsSatisfied(endEndpoint);
}
}
--
View this message in context:
http://www.nabble.com/exception-trace-in-message-tp15740418s22882p15762404.html
Sent from the Camel - Users mailing list archive at Nabble.com.
