Modified: websites/production/camel/content/error-handler.html ============================================================================== --- websites/production/camel/content/error-handler.html (original) +++ websites/production/camel/content/error-handler.html Sat Feb 4 01:20:14 2017 @@ -86,7 +86,7 @@ <tbody> <tr> <td valign="top" width="100%"> -<div class="wiki-content maincontent"><h2 id="ErrorHandler-ErrorHandler">Error Handler</h2><p>Camel supports pluggable <a shape="rect" class="external-link" href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/processor/ErrorHandler.html">ErrorHandler</a> strategies to deal with errors processing an <a shape="rect" href="event-driven-consumer.html">Event Driven Consumer</a>. An alternative is to specify the error handling directly in the <a shape="rect" href="dsl.html">DSL</a> using the <a shape="rect" href="exception-clause.html">Exception Clause</a>.</p><p>For introduction and background material see <a shape="rect" href="error-handling-in-camel.html">Error handling in Camel</a>.</p><div class="confluence-information-macro confluence-information-macro-tip"><p class="title">Exception Clause</p><span class="aui-icon aui-icon-small aui-iconfont-approve confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>Using <a shape ="rect" href="error-handler.html">Error Handler</a> combined with <a shape="rect" href="exception-clause.html">Exception Clause</a> is a very powerful combination. We encourage end-users to use this combination in your error handling strategies. See samples and <a shape="rect" href="exception-clause.html">Exception Clause</a>.</p></div></div><div class="confluence-information-macro confluence-information-macro-tip"><p class="title">Using try ... catch ... finally</p><span class="aui-icon aui-icon-small aui-iconfont-approve confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>Related to error handling is the <a shape="rect" href="try-catch-finally.html">Try Catch Finally</a> as DSL you can use directly in your route. Its basically a mimic of the regular try catch finally in the Java language but with more power.</p></div></div><p>The current implementations Camel provides out of the box are:</p><h4 id="ErrorHandler-Nontransacted">Non transacted< /h4><ul><li><a shape="rect" href="defaulterrorhandler.html">DefaultErrorHandler</a> is the default error handler in Camel. This error handler does not support a dead letter queue, it will propagate exceptions back to the caller, as if there where no error handler at all. It has a limited set of features.</li><li><a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a> which supports attempting to redeliver the message exchange a number of times before sending it to a dead letter endpoint</li><li>LoggingErrorHandler for just catching and logging exceptions</li><li>NoErrorHandler for no error handling</li></ul><h4 id="ErrorHandler-Transacted">Transacted</h4><ul><li><a shape="rect" href="transactionerrorhandler.html">TransactionErrorHandler</a> is the default error handler in Camel for transacted routes. See the <a shape="rect" href="transactional-client.html">Transactional Client</a> EIP pattern.</li></ul><p>These error handlers can be applied in the <a shape="rect" hre f="dsl.html">DSL</a> to an entire set of rules or a specific routing rule as we show in the next examples. Error handling rules are inherited on each routing rule within a single <a shape="rect" href="routebuilder.html">RouteBuilder</a></p><h3 id="ErrorHandler-ShortSummaryoftheprovidedErrorHandlers">Short Summary of the provided Error Handlers</h3><h4 id="ErrorHandler-DefaultErrorHandler"><a shape="rect" href="defaulterrorhandler.html">DefaultErrorHandler</a></h4><p>The <a shape="rect" href="defaulterrorhandler.html">DefaultErrorHandler</a> is the default error handler in Camel. Unlike <a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a> it does not have any dead letter queue, and do <strong>not</strong> handle exceptions by default.</p><h4 id="ErrorHandler-DeadLetterChannel"><a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a></h4><p>The <a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a> will redeliver at most 6 times using 1 second delay, and if the exchange failed it will be logged at ERROR level.</p><p>You can configure the default dead letter endpoint to use:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<div class="wiki-content maincontent"><h2 id="ErrorHandler-ErrorHandler">Error Handler</h2><p>Camel supports pluggable <a shape="rect" class="external-link" href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/processor/ErrorHandler.html">ErrorHandler</a> strategies to deal with errors processing an <a shape="rect" href="event-driven-consumer.html">Event Driven Consumer</a>. An alternative is to specify the error handling directly in the <a shape="rect" href="dsl.html">DSL</a> using the <a shape="rect" href="exception-clause.html">Exception Clause</a>.</p><p>For introduction and background material see <a shape="rect" href="error-handling-in-camel.html">Error handling in Camel</a>.</p><div class="confluence-information-macro confluence-information-macro-tip"><p class="title">Exception Clause</p><span class="aui-icon aui-icon-small aui-iconfont-approve confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>Using <a shape ="rect" href="error-handler.html">Error Handler</a> combined with <a shape="rect" href="exception-clause.html">Exception Clause</a> is a very powerful combination. We encourage end-users to use this combination in your error handling strategies. See samples and <a shape="rect" href="exception-clause.html">Exception Clause</a>.</p></div></div><div class="confluence-information-macro confluence-information-macro-tip"><p class="title">Using try ... catch ... finally</p><span class="aui-icon aui-icon-small aui-iconfont-approve confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>Related to error handling is the <a shape="rect" href="try-catch-finally.html">Try Catch Finally</a> as DSL you can use directly in your route. Its basically a mimic of the regular try catch finally in the Java language but with more power.</p></div></div><p>The current implementations Camel provides out of the box are:</p><h4 id="ErrorHandler-Non-transacted:">Non-transacte d<strong>:</strong></h4><ul><li><a shape="rect" href="defaulterrorhandler.html">DefaultErrorHandler</a> is the default error handler in Camel. This error handler does not support a dead letter queue, it will propagate exceptions back to the caller, as if there where no error handler at all. It has a limited set of features.</li><li><a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a> which supports attempting to redeliver the message exchange a number of times before sending it to a dead letter endpoint</li><li><strong><code>LoggingErrorHandler</code></strong> for just catching and logging exceptions</li><li><strong><code>NoErrorHandler</code></strong> for no error handling</li></ul><h4 id="ErrorHandler-Transacted:">Transacted:</h4><ul><li><a shape="rect" href="transactionerrorhandler.html">TransactionErrorHandler</a> is the default error handler in Camel for transacted routes. See the <a shape="rect" href="transactional-client.html">Transactional Client</a> EIP p attern.</li></ul><p>These error handlers can be applied in the <a shape="rect" href="dsl.html">DSL</a> to an entire set of rules or a specific routing rule as we show in the next examples. Error handling rules are inherited on each routing rule within a single <a shape="rect" href="routebuilder.html">RouteBuilder</a></p><h3 id="ErrorHandler-ShortSummaryoftheProvidedErrorHandlers">Short Summary of the Provided Error Handlers</h3><h4 id="ErrorHandler-DefaultErrorHandler"><a shape="rect" href="defaulterrorhandler.html">DefaultErrorHandler</a></h4><p>The <a shape="rect" href="defaulterrorhandler.html">DefaultErrorHandler</a> is the default error handler in Camel. Unlike <a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a> it does not have any dead letter queue, and do <strong>not</strong> handle exceptions by default.</p><h4 id="ErrorHandler-DeadLetterChannel"><a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a></h4><p>The <a shape="rect" href="dead -letter-channel.html">Dead Letter Channel</a> will redeliver at most 6 times using 1 second delay, and if the exchange failed it will be logged at <strong><code>ERROR</code></strong> level.</p><p>You can configure the default dead letter endpoint to use:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ RouteBuilder builder = new RouteBuilder() { public void configure() { @@ -98,26 +98,26 @@ RouteBuilder builder = new RouteBuilder( } }; ]]></script> -</div></div><p>or in Spring DSL</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div>or in Spring DSL:<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[<bean id="deadLetterErrorHandler" class="org.apache.camel.builder.DeadLetterChannelBuilder"> <property name="deadLetterUri" value="log:dead"/> </bean> <camelContext errorHandlerRef="deadLetterErrorHandler" xmlns="http://camel.apache.org/schema/spring"> - ... + <!-- ... --> </camelContext> ]]></script> -</div></div><p>or also from <strong>Camel 2.3.0 onwards</strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><p>or also from <strong>Camel 2.3.0:<br clear="none"></strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[<camel:errorHandler id="deadLetterErrorHandler" type="DeadLetterChannel" deadLetterUri="log:dead"> <camel:camelContext errorHandlerRef="deadLetterErrorHandler"> ... </camel:camelContext> ]]></script> -</div></div><h4 id="ErrorHandler-LoggingErrorHandler">Logging Error Handler</h4><p>The logging error handler will log (by default at ERROR level) whenever an uncaught exception is thrown. The logging category, logger and level may all be defined in the builder.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><h4 id="ErrorHandler-TheLoggingErrorHandler">The <code>LoggingErrorHandler</code></h4><p>The logging error handler will log (by default at <strong><code>ERROR</code></strong> level) whenever an uncaught exception is thrown. The logging category, logger and level may all be defined in the builder.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[errorHandler(loggingErrorHandler("mylogger.name").level(LoggingLevel.INFO)); ]]></script> -</div></div><p>or in Spring DSL</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><p>or in Spring DSL:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[<bean id="loggingErrorHandler" class="org.apache.camel.builder.LoggingErrorHandler"> <property name="logName" value="mylogger.name"/> <property name="level" value="DEBUG"/> @@ -127,34 +127,36 @@ RouteBuilder builder = new RouteBuilder( ... </camelContext> ]]></script> -</div></div><p>or also from <strong>Camel 2.3.0 onwards</strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><p>or also from <strong>Camel 2.3.0</strong>:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[<camel:errorHandler id="loggingErrorHandler" type="LoggingErrorHandler" logName="mylogger.name" level="DEBUG"/> <camel:camelContext errorHandlerRef="loggingErrorHandler"> ... </camel:camelContext> ]]></script> -</div></div><p>This would create an error handler which logs exceptions using the category mylogger.name and uses the level INFO for all log messages created.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from("seda:a").errorHandler(loggingErrorHandler("mylogger.name").level(LoggingLevel.DEBUG)).to("seda:b"); +</div></div><p>This would create an error handler which logs exceptions using the category <strong><code>mylogger.name</code></strong> and uses the level <strong><code>INFO</code></strong> for all log messages created.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from("seda:a") + .errorHandler(loggingErrorHandler("mylogger.name").level(LoggingLevel.DEBUG)) + .to("seda:b"); ]]></script> -</div></div><p>Loggers may also be defined for specific routes.</p><h4 id="ErrorHandler-NoErrorHandler">No Error Handler</h4><p>The no error handler is to be used for disabling error handling.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><p>Loggers may also be defined for specific routes.</p><h4 id="ErrorHandler-TheNoErrorHandler">The <code>NoErrorHandler</code></h4><p>The no error handler is to be used for disabling error handling.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[errorHandler(noErrorHandler()); ]]></script> -</div></div><p>or in Spring DSL</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><p>or in Spring DSL:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[<bean id="noErrorHandler" class="org.apache.camel.builder.NoErrorHandlerBuilder"/> <camelContext errorHandlerRef="noErrorHandler" xmlns="http://camel.apache.org/schema/spring"> ... </camelContext> ]]></script> -</div></div><p>or also from <strong>Camel 2.3.0 onwards</strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><p>or also from <strong>Camel 2.3.0</strong>:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[<camel:errorHandler id="noErrorHandler" type="NoErrorHandler"/> <camel:camelContext errorHandlerRef="noErrorHandler"> ... </camel:camelContext> ]]></script> -</div></div><h4 id="ErrorHandler-TransactionErrorHandler"><a shape="rect" href="transactionerrorhandler.html">TransactionErrorHandler</a></h4><p>The <a shape="rect" href="transactionerrorhandler.html">TransactionErrorHandler</a> is the default error handler in Camel for transacted routes.</p><div class="confluence-information-macro confluence-information-macro-tip"><span class="aui-icon aui-icon-small aui-iconfont-approve confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>If you have marked a route as transacted using the <strong>transacted</strong> DSL then Camel will automatic use a <a shape="rect" href="transactionerrorhandler.html">TransactionErrorHandler</a>. It will try to lookup the global/per route configured error handler and use it if its a <code>TransactionErrorHandlerBuilder</code> instance. If not Camel will automatic create a temporary <a shape="rect" href="transactionerrorhandler.html">TransactionErrorHandler</a> that overrules the default error handler. This is convention over configuration.</p></div></div><h3 id="ErrorHandler-Featuressupportbyvariouss">Features support by various <a shape="rect" href="error-handler.html">Error Handler</a>s</h3><p>Here is a breakdown of which features is supported by the <a shape="rect" href="error-handler.html">Error Handler</a>(s):</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Feature</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Supported by the following <a shape="rect" href="error-handler.html">Error Handler</a></p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>all scopes</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="defaulterrorhandler.html">DefaultErrorHandler</a>, <a shape="rect" href="transactionerrorhandler.html">TransactionErrorHandler</a>, <a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a></p></td ></tr><tr><td colspan="1" rowspan="1" >class="confluenceTd"><p>onException</p></td><td colspan="1" rowspan="1" >class="confluenceTd"><p><a shape="rect" >href="defaulterrorhandler.html">DefaultErrorHandler</a>, <a shape="rect" >href="transactionerrorhandler.html">TransactionErrorHandler</a>, <a >shape="rect" href="dead-letter-channel.html">Dead Letter >Channel</a></p></td></tr><tr><td colspan="1" rowspan="1" >class="confluenceTd"><p>onWhen</p></td><td colspan="1" rowspan="1" >class="confluenceTd"><p><a shape="rect" >href="defaulterrorhandler.html">DefaultErrorHandler</a>, <a shape="rect" >href="transactionerrorhandler.html">TransactionErrorHandler</a>, <a >shape="rect" href="dead-letter-channel.html">Dead Letter >Channel</a></p></td></tr><tr><td colspan="1" rowspan="1" >class="confluenceTd"><p>continued</p></td><td colspan="1" rowspan="1" >class="confluenceTd"><p><a shape="rect" >href="defaulterrorhandler.html">DefaultErrorHandler</a>, <a shape="rect" >href="transactionerrorhandler.html">Transaction ErrorHandler</a>, <a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>handled</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="defaulterrorhandler.html">DefaultErrorHandler</a>, <a shape="rect" href="transactionerrorhandler.html">TransactionErrorHandler</a>, <a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>Custom ExceptionPolicy</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="defaulterrorhandler.html">DefaultErrorHandler</a>, <a shape="rect" href="transactionerrorhandler.html">TransactionErrorHandler</a>, <a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>useOriginalBody</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href= "defaulterrorhandler.html">DefaultErrorHandler</a>, <a shape="rect" href="transactionerrorhandler.html">TransactionErrorHandler</a>, <a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>retryWhile</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="defaulterrorhandler.html">DefaultErrorHandler</a>, <a shape="rect" href="transactionerrorhandler.html">TransactionErrorHandler</a>, <a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>onRedelivery</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="defaulterrorhandler.html">DefaultErrorHandler</a>, <a shape="rect" href="transactionerrorhandler.html">TransactionErrorHandler</a>, <a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a></p></td></tr><tr><td colspan="1" rowspan="1" class="conflu enceTd"><p>RedeliveryPolicy</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="defaulterrorhandler.html">DefaultErrorHandler</a>, <a shape="rect" href="transactionerrorhandler.html">TransactionErrorHandler</a>, <a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>asyncDelayedRedelivery</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="defaulterrorhandler.html">DefaultErrorHandler</a>, <a shape="rect" href="transactionerrorhandler.html">TransactionErrorHandler</a>, <a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>redeliverWhileStopping</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="defaulterrorhandler.html">DefaultErrorHandler</a>, <a shape="rect" href="transactionerrorhandler.html">TransactionErrorHandler</a>, <a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>dead letter queue</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">onPrepareFailure</td><td colspan="1" rowspan="1" class="confluenceTd"><a shape="rect" href="defaulterrorhandler.html">DefaultErrorHandler</a><span>, <a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a></span></td></tr></tbody></table></div><p>See <a shape="rect" href="exception-clause.html">Exception Clause</a> documentation for documentation of some of the features above.</p><h3 id="ErrorHandler-Scopes">Scopes</h3><p>The error handler is scoped as either</p><ul class="alternate"><li>global</li><li>per route</li></ul><p>The following example shows how you can register a global error handler (in this case using th e logging handler)</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><h4 id="ErrorHandler-TransactionErrorHandler"><a shape="rect" href="transactionerrorhandler.html">TransactionErrorHandler</a></h4><p>The <a shape="rect" href="transactionerrorhandler.html">TransactionErrorHandler</a> is the default error handler in Camel for transacted routes.</p><div class="confluence-information-macro confluence-information-macro-tip"><span class="aui-icon aui-icon-small aui-iconfont-approve confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>If you have marked a route as transacted using the <strong><code>transacted</code></strong> DSL then Camel will automatic use a <a shape="rect" href="transactionerrorhandler.html">TransactionErrorHandler</a>. It will try to lookup the global/per route configured error handler and use it if its a <strong><code>TransactionErrorHandlerBuilder</code></strong> instance. If not Camel will automatic create a temporary <a shape="rect" href="transactionerrorhandler.html">TransactionE rrorHandler</a> that overrules the default error handler. This is convention over configuration.</p></div></div><h3 id="ErrorHandler-FeaturesSupportbyVariouss">Features Support by Various <a shape="rect" href="error-handler.html">Error Handler</a>s</h3><p>Here is a breakdown of which features is supported by the <a shape="rect" href="error-handler.html">Error Handler</a>(s):</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Feature</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Supported By The Following <a shape="rect" href="error-handler.html">Error Handler</a></p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>all scopes</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="defaulterrorhandler.html">DefaultErrorHandler</a>, <a shape="rect" href="transactionerrorhandler.html">TransactionErrorHandler</a>, <a shape="rect" href="dead-letter-channel.html">D ead Letter Channel</a></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>onException</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="defaulterrorhandler.html">DefaultErrorHandler</a>, <a shape="rect" href="transactionerrorhandler.html">TransactionErrorHandler</a>, <a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>onWhen</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="defaulterrorhandler.html">DefaultErrorHandler</a>, <a shape="rect" href="transactionerrorhandler.html">TransactionErrorHandler</a>, <a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>continued</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="defaulterrorhandler.html">DefaultErrorHandler </a>, <a shape="rect" href="transactionerrorhandler.html">TransactionErrorHandler</a>, <a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>handled</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="defaulterrorhandler.html">DefaultErrorHandler</a>, <a shape="rect" href="transactionerrorhandler.html">TransactionErrorHandler</a>, <a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>Custom <code>ExceptionPolicy</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="defaulterrorhandler.html">DefaultErrorHandler</a>, <a shape="rect" href="transactionerrorhandler.html">TransactionErrorHandler</a>, <a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <p><code>useOriginalBody</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="defaulterrorhandler.html">DefaultErrorHandler</a>, <a shape="rect" href="transactionerrorhandler.html">TransactionErrorHandler</a>, <a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>retryWhile</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="defaulterrorhandler.html">DefaultErrorHandler</a>, <a shape="rect" href="transactionerrorhandler.html">TransactionErrorHandler</a>, <a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>onRedelivery</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="defaulterrorhandler.html">DefaultErrorHandler</a>, <a shape="rect" href="transactionerrorhandler.html">TransactionErrorHand ler</a>, <a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>RedeliveryPolicy</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="defaulterrorhandler.html">DefaultErrorHandler</a>, <a shape="rect" href="transactionerrorhandler.html">TransactionErrorHandler</a>, <a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>asyncDelayedRedelivery</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="defaulterrorhandler.html">DefaultErrorHandler</a>, <a shape="rect" href="transactionerrorhandler.html">TransactionErrorHandler</a>, <a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>redeliverWhileStopping</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="defaulterrorhandler.html">DefaultErrorHandler</a>, <a shape="rect" href="transactionerrorhandler.html">TransactionErrorHandler</a>, <a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>dead letter queue</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>onPrepareFailure</code></td><td colspan="1" rowspan="1" class="confluenceTd"><a shape="rect" href="defaulterrorhandler.html">DefaultErrorHandler</a><span>, <a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a></span></td></tr></tbody></table></div><p>See <a shape="rect" href="exception-clause.html">Exception Clause</a> documentation for documentation of some of the features above.</p><h3 id="ErrorHandler-Scopes">Scopes</h3><p>The err or handler is scoped as either</p><ul class="alternate"><li>global</li><li>per route</li></ul><p>The following example shows how you can register a global error handler (in this case using the logging handler)</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ RouteBuilder builder = new RouteBuilder() { public void configure() { @@ -166,7 +168,7 @@ RouteBuilder builder = new RouteBuilder( } }; ]]></script> -</div></div><p>The following example shows how you can register a route specific error handler; the customized logging handler is only registered for the route from <a shape="rect" href="endpoint.html">Endpoint</a> <strong>seda:a</strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div>The following example shows how you can register a route specific error handler; the customized logging handler is only registered for the route from <a shape="rect" href="endpoint.html">Endpoint</a> <strong><code>seda:a</code></strong><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ RouteBuilder builder = new RouteBuilder() { public void configure() { @@ -182,7 +184,7 @@ RouteBuilder builder = new RouteBuilder( } }; ]]></script> -</div></div><h3 id="ErrorHandler-Springbasedconfiguration">Spring based configuration</h3><div class="confluence-information-macro confluence-information-macro-information"><p class="title">Java DSL vs. Spring DSL</p><span class="aui-icon aui-icon-small aui-iconfont-info confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>The error handler is configured a bit differently in Java DSL and Spring DSL. Spring DSL relies more on standard Spring bean configuration whereas Java DSL uses fluent builders.</p></div></div><p>The error handler can be configured as a spring bean and scoped in:</p><ul class="alternate"><li>global (the camelContext tag)</li><li>per route (the route tag)</li><li>or per policy (the policy/transacted tag)</li></ul><p>The error handler is configured with the <code>errorHandlerRef</code> attribute.</p><div class="confluence-information-macro confluence-information-macro-tip"><p class="title">Error Handler Hierarchy</p><span class ="aui-icon aui-icon-small aui-iconfont-approve confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>The error handlers is inherited, so if you only have set a global error handler then its use everywhere. But you can override this in a route and use another error handler.</p></div></div><h4 id="ErrorHandler-Springbasedconfigurationsample">Spring based configuration sample</h4><p>In this sample we configure a <a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a> on the route that should redeliver at most 3 times and use a little delay before retrying.<br clear="none"> First we configure the reference to <strong>myDeadLetterErrorHandler</strong> using the <code>errorHandlerRef</code> attribute on the <code>route</code> tag.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><h3 id="ErrorHandler-SpringBasedConfiguration">Spring Based Configuration</h3><div class="confluence-information-macro confluence-information-macro-information"><p class="title">Java DSL vs. Spring DSL</p><span class="aui-icon aui-icon-small aui-iconfont-info confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>The error handler is configured a bit differently in Java DSL and Spring DSL. Spring DSL relies more on standard Spring bean configuration whereas Java DSL uses fluent builders.</p></div></div><p>The error handler can be configured as a spring bean and scoped in:</p><ul class="alternate"><li>global (the camelContext tag)</li><li>per route (the route tag)</li><li>or per policy (the policy/transacted tag)</li></ul><p>The error handler is configured with the <strong><code>errorHandlerRef</code></strong> attribute.</p><div class="confluence-information-macro confluence-information-macro-tip"><p class="title">Error Handler Hierarc hy</p><span class="aui-icon aui-icon-small aui-iconfont-approve confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>The error handlers is inherited, so if you only have set a global error handler then its use everywhere. But you can override this in a route and use another error handler.</p></div></div><h4 id="ErrorHandler-SpringBasedConfigurationSample">Spring Based Configuration Sample</h4><p>In this sample we configure a <a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a> on the route that should redeliver at most 3 times and use a little delay before retrying.<br clear="none"> First, we configure the reference to <strong><code>myDeadLetterErrorHandler</code></strong> using the <strong><code>errorHandlerRef</code></strong> attribute on the <code>route</code> tag.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ <camelContext xmlns="http://camel.apache.org/schema/spring"> <template id="myTemplate"/> @@ -194,7 +196,7 @@ RouteBuilder builder = new RouteBuilder( </route> </camelContext> ]]></script> -</div></div><p>Then we configure <strong>myDeadLetterErrorHandler</strong> that is our <a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a>. This configuration is standard Spring using the bean element.<br clear="none"> And finally we have another spring bean for the redelivery policy where we can configure the options for how many times to redeliver, delays etc.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div>Then we configure <strong><code>myDeadLetterErrorHandler</code></strong> that is our <a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a>. This configuration is standard Spring using the bean element.<br clear="none">Finally, we have another spring bean for the redelivery policy where we can configure the options for how many times to redeliver, delays etc.<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ <!-- here we configure our DeadLetterChannel --> <bean id="myDeadLetterErrorHandler" class="org.apache.camel.builder.DeadLetterChannelBuilder"> @@ -212,7 +214,7 @@ RouteBuilder builder = new RouteBuilder( <property name="redeliveryDelay" value="250"/> </bean> ]]></script> -</div></div><p>From Camel 2.3.0, camel provides a customer bean configuration for the Error Handler, you can find the examples here.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div>From <strong>Camel 2.3.0</strong>, camel provides a customer bean configuration for the Error Handler, you can find the examples here.<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ <errorHandler id="loggingErrorHandler" type="LoggingErrorHandler" logName="foo" level="INFO" xmlns="http://camel.apache.org/schema/spring"/> @@ -242,7 +244,7 @@ RouteBuilder builder = new RouteBuilder( <errorHandler id="noErrorHandler" type="NoErrorHandler"/> </camelContext> ]]></script> -</div></div><h3 id="ErrorHandler-Usingthetransactionalerrorhandler">Using the transactional error handler</h3><p>The transactional error handler is based on spring transaction. This requires the usage of the camel-spring component.<br clear="none"> See <a shape="rect" href="transactional-client.html">Transactional Client</a> that has many samples for how to use and transactional behavior and configuration with this error handler.</p><h3 id="ErrorHandler-Seealso">See also</h3><ul class="alternate"><li><a shape="rect" href="error-handling-in-camel.html">Error handling in Camel</a> for introduction and background material on error handling in Camel</li><li><a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a> for the dead letter error handler</li><li><a shape="rect" href="defaulterrorhandler.html">DefaultErrorHandler</a> for the default error handler in Camel</li><li><a shape="rect" href="transactionerrorhandler.html">TransactionErrorHandler</a> for the default error handler for transacted routes</li><li><a shape="rect" href="transactional-client.html">Transactional Client</a> for transactional behavior</li><li><a shape="rect" href="exception-clause.html">Exception Clause</a> as it supports <strong>handling</strong> thrown exceptions</li><li><a shape="rect" href="try-catch-finally.html">Try Catch Finally</a> for try ... catch ... finally as DSL you can use in the routing</li></ul></div> +</div></div><h3 id="ErrorHandler-UsingtheTransactionalErrorHandler">Using the <code>TransactionalErrorHandler</code></h3><p>The <strong><code>TransactionalErrorHandler</code></strong> is based on spring transaction. This requires the usage of the camel-spring component. See <a shape="rect" href="transactional-client.html">Transactional Client</a> that has many samples for how to use and transactional behavior and configuration with this error handler.</p><h3 id="ErrorHandler-Seealso">See also</h3><ul class="alternate"><li><a shape="rect" href="error-handling-in-camel.html">Error handling in Camel</a> for introduction and background material on error handling in Camel</li><li><a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a> for the dead letter error handler</li><li><a shape="rect" href="defaulterrorhandler.html">DefaultErrorHandler</a> for the default error handler in Camel</li><li><a shape="rect" href="transactionerrorhandler.html">TransactionErrorHa ndler</a> for the default error handler for transacted routes</li><li><a shape="rect" href="transactional-client.html">Transactional Client</a> for transactional behavior</li><li><a shape="rect" href="exception-clause.html">Exception Clause</a> as it supports <strong>handling</strong> thrown exceptions</li><li><a shape="rect" href="try-catch-finally.html">Try Catch Finally</a> for try ... catch ... finally as DSL you can use in the routing</li></ul></div> </td> <td valign="top"> <div class="navigation">