camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Magnus Heino" <mag...@filur.org>
Subject Re: exception trace in message
Date Mon, 10 Mar 2008 10:59:58 GMT
Did anyone come up with a working solution for this?

DeadLetterChannel.EXCEPTION_CAUSE_PROPERTY is not used or tested anywhere.
And even if that was not the case, dead letter channel isn't the same as
exception() and tryBlock(), right?

I also looked through all the
org.apache.camel.processor.Validation*Testtests, but none of them
expose or use the actual exception.

Is this possible? It seems weird to have a xml schema validation component
if it's impossible to get hold of the actual error message...

/Magnus

On Fri, Feb 29, 2008 at 5:39 PM, cmdr <spcmdr@yahoo.fr> wrote:

>
> 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.
>
>


-- 

 /Magnus Heino

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message