Author: buildbot
Date: Tue Oct 21 08:18:24 2014
New Revision: 926300

Log:
Production update by buildbot for camel

Modified:
    websites/production/camel/content/cache/main.pageCache
    websites/production/camel/content/try-catch-finally.html

Modified: websites/production/camel/content/cache/main.pageCache
==============================================================================
Binary files - no diff available.

Modified: websites/production/camel/content/try-catch-finally.html
==============================================================================
--- websites/production/camel/content/try-catch-finally.html (original)
+++ websites/production/camel/content/try-catch-finally.html Tue Oct 21 
08:18:24 2014
@@ -86,41 +86,26 @@
        <tbody>
         <tr>
         <td valign="top" width="100%">
-<div class="wiki-content maincontent"><h2 
id="TryCatchFinally-Try...Catch...Finally">Try ... Catch ... Finally</h2>
-<p>Camel supports the Java equivalent of try .. catch and finally directly in 
the DSL.<br clear="none">
-It aims to work like its Java sisters but with more power. Especially in Camel 
2.0 where we gave this feature an overhaul.</p>
-
-<p>In Camel we prefix the keywords with <code>do</code> to avoid having same 
keyword as Java. So we have:</p>
-<ul 
class="alternate"><li><code>doTry</code></li><li><code>doCatch</code></li><li><code>doFinally</code></li><li><code>end</code>
 to end the block in Java DSL</li></ul>
-
-
-<p>Notice this document is based on how it works in Camel 2.0. In Camel 1.x 
this feature isn't as powerful and it uses a slight different keyword names.</p>
-
-    <div class="aui-message hint shadowed information-macro">
+<div class="wiki-content maincontent"><h2 
id="TryCatchFinally-Try...Catch...Finally">Try ... Catch ... 
Finally</h2><p>Camel supports the Java equivalent of try .. catch and finally 
directly in the DSL.<br clear="none"> It aims to work like its Java sisters but 
with more power. Especially in Camel 2.0 where we gave this feature an 
overhaul.</p><p>In Camel we prefix the keywords with <code>do</code> to avoid 
having same keyword as Java. So we have:</p><ul 
class="alternate"><li><code>doTry</code></li><li><code>doCatch</code></li><li><code>doFinally</code></li><li><code>end</code>
 to end the block in Java DSL</li></ul><p>Notice this document is based on how 
it works in Camel 2.0. In Camel 1.x this feature isn't as powerful and it uses 
a slight different keyword names.</p>    <div class="aui-message hint shadowed 
information-macro">
                     <p class="title">Camel error handling is disabled</p>
                             <span class="aui-icon icon-hint">Icon</span>
                 <div class="message-content">
-                            
-<p>When using <code>doTry .. doCatch .. doFinally</code> then the regular 
Camel <a shape="rect" href="error-handler.html">Error Handler</a> does not 
apply. That means any <code>onException</code> or the likes does not trigger. 
The reason is that <code>doTry .. doCatch .. doFinally</code> is in fact its 
own error handler and that it aims to mimic and work like how try/catch/finally 
works in Java.</p>
+                            <p>When using <code>doTry .. doCatch .. 
doFinally</code> then the regular Camel <a shape="rect" 
href="error-handler.html">Error Handler</a> does not apply. That means any 
<code>onException</code> or the likes does not trigger. The reason is that 
<code>doTry .. doCatch .. doFinally</code> is in fact its own error handler and 
that it aims to mimic and work like how try/catch/finally works in Java.</p>
                     </div>
     </div>
-
-
-<h3 id="TryCatchFinally-AboutdoCatchanditspoweroverJava">About 
<code>doCatch</code> and its power over Java</h3>
-<p>The <code>doCatch</code> in Camel is empowered over its Java sister.</p>
-
-<p>First of all you can define multiple exceptions to catch in a single 
block.</p>
-
-<p>And second of all an important aspect over the regular Java counter parts 
is that Camel will check in the exception hierarchy when it matches a thrown 
exception against the <code>doCatch</code> blocks. The reasons is that many 
times the original caused exceptions is wrapped by other wrapper exceptions, 
typically transposing the exception from a checked to a runtime exception.<br 
clear="none">
-Camel for instance does this by wrapped it in a 
<code>CamelRuntimeException</code>. So if the original caused exception is an 
<code>java.io.IOException</code> then Camel will still match a 
<code>doCatch</code> block defined with an <code>java.io.IOException</code>. 
And just like Java the order in which you have multiple <code>doCatch</code> 
blocks matter. Camel will iterate from the top going down and use the first 
<code>doCatch</code> that matches the exception. The reason is to keep it 
similar to the regular java and how it selects a catch block. This differers 
from the <a shape="rect" href="exception-clause.html">Exception Clause</a> that 
has a more intelligent exception selection strategy among multiple 
<code>onException</code> definitions, where it also consider the delta in the 
exception hierarchy to select the best definition.</p>
-
-<p>A third feature is that you can attach a <code>onWhen</code> predicate to 
signal if the catch should trigger or not at runtime.</p>
-
-<p>And to simulate <em>rethrowing</em> an exception from a 
<code>doCatch</code> you should use the <code>handled</code> predicate. If its 
evaluated to <code>false</code> Camel will reattach the exception on the <a 
shape="rect" href="exchange.html">Exchange</a>. </p>
-
-<h3 id="TryCatchFinally-Usingtry..catch..finallyinJavaDSL">Using try .. catch 
.. finally in Java DSL</h3>
-<p>In the route below we have all keywords in action. As the code is based on 
a unit test we route using <a shape="rect" href="mock.html">Mock</a>.</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
+<h3 
id="TryCatchFinally-doTryaroundaContentBasedRouternotsupported"><code>doTry</code>
 around a Content Based Router not supported</h3><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: java; gutter: false" 
type="syntaxhighlighter"><![CDATA[from(&quot;direct:dotry&quot;).setExchangePattern(ExchangePattern.InOut)
+           .doTry()
+              .to(&quot;https://localhost:8080/rest/order/123&quot;)
+              .choice()
+                  .when().simple(&quot;${header.CamelHttpResponseCode} == 
&#39;200&#39;&quot;)
+                     .convertBodyTo(String.class)
+                                // DO SOMETHING
+                .endChoice()
+           .doCatch(Exception.class) // NOT SUPPORTED !!
+              .log(&quot;&gt;&gt; Exception&quot;)
+           .endDoTry();]]></script>
+</div></div><p><span style="color: rgb(34,34,34);"><br 
clear="none"></span></p><p><span style="color: rgb(34,34,34);">The 
ChoiceDefinition class which is part of the DSL language of Apache Camel to 
implement the Content Based Router EIP Pattern doesn&#8217;t extends the 
OutputDefinition, which means that you cannot define the doCatch after the 
ChoiceDefinition as presented with the previous example.&#160;</span><span 
style="color: rgb(34,34,34);">If you want to catch the exception inside of 
ChoiceDefinition, you can use error handler or use doTry&#8230;doCatch inside 
of when part.</span></p><h3 
id="TryCatchFinally-AboutdoCatchanditspoweroverJava">About <code>doCatch</code> 
and its power over Java</h3><p>The <code>doCatch</code> in Camel is empowered 
over its Java sister.</p><p>First of all you can define multiple exceptions to 
catch in a single block.</p><p>And second of all an important aspect over the 
regular Java counter parts is that Camel will check in the exception hierarchy w
 hen it matches a thrown exception against the <code>doCatch</code> blocks. The 
reasons is that many times the original caused exceptions is wrapped by other 
wrapper exceptions, typically transposing the exception from a checked to a 
runtime exception.<br clear="none"> Camel for instance does this by wrapped it 
in a <code>CamelRuntimeException</code>. So if the original caused exception is 
an <code>java.io.IOException</code> then Camel will still match a 
<code>doCatch</code> block defined with an <code>java.io.IOException</code>. 
And just like Java the order in which you have multiple <code>doCatch</code> 
blocks matter. Camel will iterate from the top going down and use the first 
<code>doCatch</code> that matches the exception. The reason is to keep it 
similar to the regular java and how it selects a catch block. This differers 
from the <a shape="rect" href="exception-clause.html">Exception Clause</a> that 
has a more intelligent exception selection strategy among multiple <code>onExc
 eption</code> definitions, where it also consider the delta in the exception 
hierarchy to select the best definition.</p><p>A third feature is that you can 
attach a <code>onWhen</code> predicate to signal if the catch should trigger or 
not at runtime.</p><p>And to simulate <em>rethrowing</em> an exception from a 
<code>doCatch</code> you should use the <code>handled</code> predicate. If its 
evaluated to <code>false</code> Camel will reattach the exception on the <a 
shape="rect" href="exchange.html">Exchange</a>.</p><h3 
id="TryCatchFinally-Usingtry..catch..finallyinJavaDSL">Using try .. catch .. 
finally in Java DSL</h3><p>In the route below we have all keywords in action. 
As the code is based on a unit test we route using <a shape="rect" 
href="mock.html">Mock</a>.</p><div class="code panel pdl" style="border-width: 
1px;"><div class="codeContent panelContent pdl">
 <script class="theme: Default; brush: java; gutter: false" 
type="syntaxhighlighter"><![CDATA[
 from(&quot;direct:start&quot;)
     .doTry()
@@ -132,11 +117,7 @@ from(&quot;direct:start&quot;)
         .to(&quot;mock:finally&quot;)
     .end();
 ]]></script>
-</div></div>
-
-<p>And in the route below we want to indicate if an IOException occured we 
want to route it elsewhere and at the same time keep the exception so the 
original caller is notified about this exception. To do this we need to not 
<em>rethrow</em> the exception and this is why we use <strong>handled</strong> 
and set it to false to indicate, no we did not handle it so please keep the 
exception.<br clear="none">
-The 2nd exception block can be omitted but as the code is based on an unit 
test we want to test the behavior non <code>IOException</code> as well.</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
+</div></div><p>And in the route below we want to indicate if an IOException 
occured we want to route it elsewhere and at the same time keep the exception 
so the original caller is notified about this exception. To do this we need to 
not <em>rethrow</em> the exception and this is why we use 
<strong>handled</strong> and set it to false to indicate, no we did not handle 
it so please keep the exception.<br clear="none"> The 2nd exception block can 
be omitted but as the code is based on an unit test we want to test the 
behavior non <code>IOException</code> as well.</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <script class="theme: Default; brush: java; gutter: false" 
type="syntaxhighlighter"><![CDATA[
 from(&quot;direct:start&quot;)
     // here is our try where we try processing the exchange in the route below 
if it fails
@@ -156,11 +137,7 @@ from(&quot;direct:start&quot;)
     // here the try block ends
     .end();
 ]]></script>
-</div></div>
-
-<p>And finally we have an example of the <code>onWhen</code> predicate in 
action. We can attach it to a <code>doCatch</code> block and at runtime 
determine if the block should be triggered or not.<br clear="none">
-In our case we only want to trigger if the caused exception message contains 
the <strong>damn</strong> word.</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
+</div></div><p>And finally we have an example of the <code>onWhen</code> 
predicate in action. We can attach it to a <code>doCatch</code> block and at 
runtime determine if the block should be triggered or not.<br clear="none"> In 
our case we only want to trigger if the caused exception message contains the 
<strong>damn</strong> word.</p><div class="code panel pdl" style="border-width: 
1px;"><div class="codeContent panelContent pdl">
 <script class="theme: Default; brush: java; gutter: false" 
type="syntaxhighlighter"><![CDATA[
 from(&quot;direct:start&quot;)
     // here is our try where we try processing the exchange in the route below 
if it fails
@@ -183,23 +160,14 @@ from(&quot;direct:start&quot;)
     // here the try block ends
     .end();
 ]]></script>
-</div></div>
-
-    <div class="aui-message success shadowed information-macro">
+</div></div>    <div class="aui-message success shadowed information-macro">
                     <p class="title">Use end() to end the block</p>
                             <span class="aui-icon icon-success">Icon</span>
                 <div class="message-content">
-                            
-<p>Notice when using Java DSL we must use <code>end()</code> to indicate where 
the try .. catch .. finally block ends. As the example above has a finally, 
then the <code>end()</code> should be at the end of the finally block. If we 
are not using a finally, then the <code>end()</code> should be at the end of 
the <code>doCatch</code> to indicate the end there.</p>
+                            <p>Notice when using Java DSL we must use 
<code>end()</code> to indicate where the try .. catch .. finally block ends. As 
the example above has a finally, then the <code>end()</code> should be at the 
end of the finally block. If we are not using a finally, then the 
<code>end()</code> should be at the end of the <code>doCatch</code> to indicate 
the end there.</p>
                     </div>
     </div>
-
-
-<h3 id="TryCatchFinally-Usingtry..catch..finallyinSpringDSL">Using try .. 
catch .. finally in Spring DSL</h3>
-<p>We show the three sample samples using Spring DSL instead.</p>
-
-<p>In the route below we have all keywords in action. As the code is based on 
a unit test we route using <a shape="rect" href="mock.html">Mock</a>.</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
+<h3 id="TryCatchFinally-Usingtry..catch..finallyinSpringDSL">Using try .. 
catch .. finally in Spring DSL</h3><p>We show the three sample samples using 
Spring DSL instead.</p><p>In the route below we have all keywords in action. As 
the code is based on a unit test we route using <a shape="rect" 
href="mock.html">Mock</a>.</p><div class="code panel pdl" style="border-width: 
1px;"><div class="codeContent panelContent pdl">
 <script class="theme: Default; brush: xml; gutter: false" 
type="syntaxhighlighter"><![CDATA[
 &lt;route&gt;
     &lt;from uri=&quot;direct:start&quot;/&gt;
@@ -219,11 +187,7 @@ from(&quot;direct:start&quot;)
     &lt;/doTry&gt;
 &lt;/route&gt;
 ]]></script>
-</div></div>
-
-<p>And in the route below we want to indicate if an IOException occured we 
want to route it elsewhere and at the same time keep the exception so the 
original caller is notified about this exception. To do this we need to not 
<em>rethrow</em> the exception and this is why we use <strong>handled</strong> 
and set it to false to indicate, no we did not handle it so please keep the 
exception.<br clear="none">
-The 2nd exception block can be omitted but as the code is based on an unit 
test we want to test the behavior non <code>IOException</code> as well.</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
+</div></div><p>And in the route below we want to indicate if an IOException 
occured we want to route it elsewhere and at the same time keep the exception 
so the original caller is notified about this exception. To do this we need to 
not <em>rethrow</em> the exception and this is why we use 
<strong>handled</strong> and set it to false to indicate, no we did not handle 
it so please keep the exception.<br clear="none"> The 2nd exception block can 
be omitted but as the code is based on an unit test we want to test the 
behavior non <code>IOException</code> as well.</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <script class="theme: Default; brush: xml; gutter: false" 
type="syntaxhighlighter"><![CDATA[
 &lt;route&gt;
     &lt;from uri=&quot;direct:start&quot;/&gt;
@@ -248,11 +212,7 @@ The 2nd exception block can be omitted b
     &lt;/doTry&gt;
 &lt;/route&gt;
 ]]></script>
-</div></div>
-
-<p>And finally we have an example of the <code>onWhen</code> predicate in 
action. We can attach it to a <code>doCatch</code> block and at runtime 
determine if the block should be triggered or not.<br clear="none">
-In our case we only want to trigger if the caused exception message contains 
the <strong>damn</strong> word.</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
+</div></div><p>And finally we have an example of the <code>onWhen</code> 
predicate in action. We can attach it to a <code>doCatch</code> block and at 
runtime determine if the block should be triggered or not.<br clear="none"> In 
our case we only want to trigger if the caused exception message contains the 
<strong>damn</strong> word.</p><div class="code panel pdl" style="border-width: 
1px;"><div class="codeContent panelContent pdl">
 <script class="theme: Default; brush: xml; gutter: false" 
type="syntaxhighlighter"><![CDATA[
 &lt;route&gt;
     &lt;from uri=&quot;direct:start&quot;/&gt;
@@ -282,11 +242,7 @@ In our case we only want to trigger if t
     &lt;/doTry&gt;
 &lt;/route&gt;
 ]]></script>
-</div></div>
-
-<h3 id="TryCatchFinally-SeeAlso">See Also</h3>
-<ul class="alternate"><li><a shape="rect" 
href="error-handling-in-camel.html">Error handling in Camel</a></li><li><a 
shape="rect" href="error-handler.html">Error Handler</a></li><li><a 
shape="rect" href="exception-clause.html">Exception Clause</a></li></ul>
-</div>
+</div></div><h3 id="TryCatchFinally-SeeAlso">See Also</h3><ul 
class="alternate"><li><a shape="rect" href="error-handling-in-camel.html">Error 
handling in Camel</a></li><li><a shape="rect" href="error-handler.html">Error 
Handler</a></li><li><a shape="rect" href="exception-clause.html">Exception 
Clause</a></li></ul></div>
         </td>
         <td valign="top">
           <div class="navigation">


Reply via email to