You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Felix Thomas <fe...@gmail.com> on 2015/08/10 13:19:31 UTC

Logging Error in Message or Exchange in DB (Not getting the exception in Processor)

Hello,

      I tried the Below error Handling using DeadLetterChannel , but
currently I am not getting the exception or error in my processor . I want
to log in DB the message along with the reason it failed , for example JDBC
exception, Null pointer exception , data Validation exception  in some
method etc.


   <bean id="myErrorHandler"
class="org.apache.camel.builder.DeadLetterChannelBuilder">
            <property name="deadLetterUri" value="direct:myErrorRoute"/>
            <property name="redeliveryPolicy"
ref="myRedeliveryPolicyConfig"/>
        </bean>

        <bean id="myRedeliveryPolicyConfig"
class="org.apache.camel.processor.RedeliveryPolicy">
            <property name="maximumRedeliveries" value="1"/>
            <property name="redeliveryDelay" value="5000"/>
            <property name="allowRedeliveryWhileStopping" value="false"/>
        </bean>


<!--  Error Handler Generic one -->
    <route customId="false" id="myErrorRoute" xmlns="
http://camel.apache.org/schema/spring">
        <from uri="direct:myErrorRoute"/>
        <process  ref="CustomErrorProcessor"/>
        <to uri="mock:end"/>
    </route>

 In the Error Processor is called proper on Exception, But I dont get an
Exception from  exchange object nor Fault from the message object.

i tried the below flags too. exchange.isFailed()  and message.isFault()
but returned false.  While in the Logs I can see the exception printed

2015-08-10 12:19:19,218 [read #8 - Split] DEBUG
DeadLetterChannel              - Failed delivery for (MessageId:
ID-DEACR002901-62175-1439201946611-0-1 on ExchangeId:
ID-DEACR002901-62175-1439201946611-0-10). On delivery attempt: 0 caught:
java.lang.NullPointerException

Failed delivery for (MessageId: ID-DEACR002901-62175-1439201946611-0-1 on
ExchangeId: ID-DEACR002901-62175-1439201946611-0-14). On delivery attempt:
1 caught: java.lang.NullPointerException


How do I get the Origin of the exception in my errorprocessor.


regards,
Felix T

Re: Logging Error in Message or Exchange in DB (Not getting the exception in Processor)

Posted by Claus Ibsen <cl...@gmail.com>.
Yes the error handler / onException only routes when exhausted.


On Mon, Aug 10, 2015 at 2:06 PM, fxthomas <fe...@gmail.com> wrote:
> okay, worked Like a Charm.
>
> Just a question, the ErrorProcessor will be called once only after the
> redelivery policy limit is exhausted  I hope not for every re delivery.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Logging-Error-in-Message-or-Exchange-in-DB-Not-getting-the-exception-in-Processor-tp5770526p5770528.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2nd edition: http://www.manning.com/ibsen2

Re: Logging Error in Message or Exchange in DB (Not getting the exception in Processor)

Posted by fxthomas <fe...@gmail.com>.
okay, worked Like a Charm.  

Just a question, the ErrorProcessor will be called once only after the
redelivery policy limit is exhausted  I hope not for every re delivery.



--
View this message in context: http://camel.465427.n5.nabble.com/Logging-Error-in-Message-or-Exchange-in-DB-Not-getting-the-exception-in-Processor-tp5770526p5770528.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Logging Error in Message or Exchange in DB (Not getting the exception in Processor)

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

See this FAQ
http://camel.apache.org/why-is-the-exception-null-when-i-use-onexception.html

On Mon, Aug 10, 2015 at 1:19 PM, Felix Thomas <fe...@gmail.com> wrote:
> Hello,
>
>       I tried the Below error Handling using DeadLetterChannel , but
> currently I am not getting the exception or error in my processor . I want
> to log in DB the message along with the reason it failed , for example JDBC
> exception, Null pointer exception , data Validation exception  in some
> method etc.
>
>
>    <bean id="myErrorHandler"
> class="org.apache.camel.builder.DeadLetterChannelBuilder">
>             <property name="deadLetterUri" value="direct:myErrorRoute"/>
>             <property name="redeliveryPolicy"
> ref="myRedeliveryPolicyConfig"/>
>         </bean>
>
>         <bean id="myRedeliveryPolicyConfig"
> class="org.apache.camel.processor.RedeliveryPolicy">
>             <property name="maximumRedeliveries" value="1"/>
>             <property name="redeliveryDelay" value="5000"/>
>             <property name="allowRedeliveryWhileStopping" value="false"/>
>         </bean>
>
>
> <!--  Error Handler Generic one -->
>     <route customId="false" id="myErrorRoute" xmlns="
> http://camel.apache.org/schema/spring">
>         <from uri="direct:myErrorRoute"/>
>         <process  ref="CustomErrorProcessor"/>
>         <to uri="mock:end"/>
>     </route>
>
>  In the Error Processor is called proper on Exception, But I dont get an
> Exception from  exchange object nor Fault from the message object.
>
> i tried the below flags too. exchange.isFailed()  and message.isFault()
> but returned false.  While in the Logs I can see the exception printed
>
> 2015-08-10 12:19:19,218 [read #8 - Split] DEBUG
> DeadLetterChannel              - Failed delivery for (MessageId:
> ID-DEACR002901-62175-1439201946611-0-1 on ExchangeId:
> ID-DEACR002901-62175-1439201946611-0-10). On delivery attempt: 0 caught:
> java.lang.NullPointerException
>
> Failed delivery for (MessageId: ID-DEACR002901-62175-1439201946611-0-1 on
> ExchangeId: ID-DEACR002901-62175-1439201946611-0-14). On delivery attempt:
> 1 caught: java.lang.NullPointerException
>
>
> How do I get the Origin of the exception in my errorprocessor.
>
>
> regards,
> Felix T



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2nd edition: http://www.manning.com/ibsen2