You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by brnzn1 <or...@aimia.com> on 2013/05/21 10:27:05 UTC

unable to propagate exceptions to global error handler from SedaConsumer

Hi,

I am using Camel 2.10.4.

I would like to retry from some exceptions like connection timeout, but
anything else I would like to propagate to the global error handler (camel
context error handler).

I have the following spring context:
<bean id="myRecipientListBean" class="com.foo.MyRecipientListBean"/>

<bean id="myRouteBuilder" class="com.foo.MyRouteBuilder"/> 

<errorHandler id="deadLetterErrorHandler"  type="DeadLetterChannel"
useOriginalMessage="true"
                  deadLetterUri="direct:myDLC"
xmlns="http://camel.apache.org/schema/spring">
        <redeliveryPolicy maximumRedeliveries="2" redeliveryDelay="5"
                          retriesExhaustedLogLevel="ERROR"
logStackTrace="true" logRetryAttempted="true"
                          logRetryStackTrace="false" logHandled="true"
                          retryAttemptedLogLevel="ERROR" />
    </errorHandler>

 <camelContext xmlns="http://camel.apache.org/schema/spring"
autoStartup="false"  id="mreCamelContext" handleFault="true"
errorHandlerRef="deadLetterErrorHandler">
        <routeBuilder  ref="myRouteBuilder" />

         <route>
             <from uri="direct:myDLC"/>
             <log message="===============> Got error......."
logName="stdout" loggingLevel="ERROR"/>
         </route>
    </camelContext>

MyRouteBuilder bean creates the following route:
errorHandler(noErrorHandler());
from("activemq:queue...").beanRef("myRecipientListBean");

MyRecipientListBean return a list of endpoints in the format seda:bean1 etc. 

The seda endpoints are added to the camel context at runtime using the
following route:
               
onException(ResourceAccessException.class).handled(true).maximumRedeliveries(1).log(LoggingLevel.ERROR,
"Failed to process message: [${body}] \n
exception[${exception.stacktrace}]").to(MY_DLQ);

onException(DataAccessResourceFailureException.class).handled(true).maximumRedeliveries(1).log(LoggingLevel.ERROR,
"Failed to process message: [${body}] \n
exception[${exception.stacktrace}]").to(MY_DLQ);

errorHandler(noErrorHandler());
from("seda:bean1").routeId("bean1").bean(bean1, "execute");

The onException seems to work fine, however if I throw NullPointerException
from Bean1 then it get handled by SedaConsumer, which log it:
2013-05-21 09:12:44 o.a.c.c.s.SedaConsumer [WARN] Error processing exchange.
Exchange[JmsMessage[JmsMessageID: ID:1369123961767-3:1:2:1:1]]. Caused by:
[java.lang.NullPointerException - test error]
java.lang.NullPointerException: test error

I tried setting errorHandler(noErrorHandler()); on both routes or set
DeadLetterChannel etc, but no success.

What am I doing wrong?

Thank




--
View this message in context: http://camel.465427.n5.nabble.com/unable-to-propagate-exceptions-to-global-error-handler-from-SedaConsumer-tp5732876.html
Sent from the Camel - Users mailing list archive at Nabble.com.