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/12 10:20:10 UTC

Getting both Original Message Body & Modified Message Body on Any error/Exception in Routes

Hello,

     I have configured my DeadLetterchannel as below  .  I am getting the
Oriiginal  Body  in the ErrorHandler , But i want to have the original and
the modified body which I need to log in a DB at a Global Level.   Is it
Possible to get Both in the Message Object.??

Below the config.

   <bean id="myErrorHandler"
class="org.apache.camel.builder.DeadLetterChannelBuilder">
            <property name="deadLetterUri" value="direct:myErrorRoute"/>
            <property name="redeliveryPolicy"
ref="myRedeliveryPolicyConfig"/>
  <property name="useOriginalMessage" value="true"/>
        </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:fridaErrorRoute"/>
        <transform>
                <method ref="CustomErrorProcessorBean"
method="createErrorEntry" />
        </transform>
        <to uri="sqlComponent:{{sql.insertNewError}}" />
    </route>

Regards,
Felix T

Re: Getting both Original Message Body & Modified Message Body on Any error/Exception in Routes

Posted by Claus Ibsen <cl...@gmail.com>.
You can flip it around and turn off that option on error handler. Then
from the exchange unit of work you can get access to the original
message. There is Java API for that.

On Wed, Aug 12, 2015 at 10:20 AM, Felix Thomas <fe...@gmail.com> wrote:
> Hello,
>
>      I have configured my DeadLetterchannel as below  .  I am getting the
> Oriiginal  Body  in the ErrorHandler , But i want to have the original and
> the modified body which I need to log in a DB at a Global Level.   Is it
> Possible to get Both in the Message Object.??
>
> Below the config.
>
>    <bean id="myErrorHandler"
> class="org.apache.camel.builder.DeadLetterChannelBuilder">
>             <property name="deadLetterUri" value="direct:myErrorRoute"/>
>             <property name="redeliveryPolicy"
> ref="myRedeliveryPolicyConfig"/>
>   <property name="useOriginalMessage" value="true"/>
>         </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:fridaErrorRoute"/>
>         <transform>
>                 <method ref="CustomErrorProcessorBean"
> method="createErrorEntry" />
>         </transform>
>         <to uri="sqlComponent:{{sql.insertNewError}}" />
>     </route>
>
> Regards,
> Felix T



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