You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by bu...@apache.org on 2013/06/24 13:18:14 UTC

svn commit: r867196 - in /websites/production/camel/content: cache/main.pageCache try-catch-finally.html

Author: buildbot
Date: Mon Jun 24 11:18:14 2013
New Revision: 867196

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 Mon Jun 24 11:18:14 2013
@@ -35,6 +35,8 @@
     </style>
     <![endif]-->
 
+
+
     <title>
     Apache Camel: Try Catch Finally
     </title>
@@ -52,8 +54,8 @@
     <div class="content_r">
       <div>
           <!-- Banner -->
-<div id="banner-content">
-	<div id="asf_logo">
+<div id="banner-content"><p>
+	</p><div id="asf_logo">
 	<div id="activemq_logo" style="height:108px; background:transparent url(banner.data/apache-camel-7.png) no-repeat scroll left top;">
             <a shape="rect" style="float:left; width:310px;display:block;text-indent:-5000px;text-decoration:none;line-height:140px; margin-top:20px; margin-left:18px;" href="http://camel.apache.org/">Camel</a>
             <a shape="rect" style="float:right; width:180px;display:block;text-indent:-5000px;text-decoration:none;line-height:80px; margin-top:45px; margin-right:10px;" href="http://www.apache.org">Apache</a>
@@ -97,157 +99,147 @@ Camel for instance does this by wrapped 
 
 <p>A third feature is that you can attach a <tt>onWhen</tt> predicate to signal if the catch should trigger or not at runtime.</p>
 
-<p>And to simulate <em>rehrowing</em> an exception from a <tt>doCatch</tt> you should use the <tt>handled</tt> predicate. If its evaluated to <tt>false</tt> Camel will reattach the exception on the <a shape="rect" href="exchange.html" title="Exchange">Exchange</a>. </p>
+<p>And to simulate <em>rethrowing</em> an exception from a <tt>doCatch</tt> you should use the <tt>handled</tt> predicate. If its evaluated to <tt>false</tt> Camel will reattach the exception on the <a shape="rect" href="exchange.html" title="Exchange">Exchange</a>. </p>
 
 <h3><a shape="rect" name="TryCatchFinally-Usingtry..catch..finallyinJavaDSL"></a>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" title="Mock">Mock</a>.</p>
-<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">from(<span class="code-quote">"direct:start"</span>)
-    .doTry()
-        .process(<span class="code-keyword">new</span> ProcessorFail())
-        .to(<span class="code-quote">"mock:result"</span>)
-    .doCatch(IOException.class, IllegalStateException.class)
-        .to(<span class="code-quote">"mock:<span class="code-keyword">catch</span>"</span>)
-    .doFinally()
-        .to(<span class="code-quote">"mock:<span class="code-keyword">finally</span>"</span>)
-    .end();
-</pre>
-</div></div>
+<div class="error"><span class="error">Unknown macro: {code}</span> 
+<p>from("direct:start")<br clear="none">
+    .doTry()<br clear="none">
+        .process(new ProcessorFail())<br clear="none">
+        .to("mock:result")<br clear="none">
+    .doCatch(IOException.class, IllegalStateException.class)<br clear="none">
+        .to("mock:catch")<br clear="none">
+    .doFinally()<br clear="none">
+        .to("mock:finally")<br clear="none">
+    .end();</p></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 <b>handled</b> 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 <tt>IOException</tt> as well.</p>
-<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">from(<span class="code-quote">"direct:start"</span>)
-    <span class="code-comment">// here is our <span class="code-keyword">try</span> where we <span class="code-keyword">try</span> processing the exchange in the route below <span class="code-keyword">if</span> it fails
-</span>    <span class="code-comment">// we can <span class="code-keyword">catch</span> it below, just like regular <span class="code-keyword">try</span> .. <span class="code-keyword">catch</span> .. <span class="code-keyword">finally</span> in Java
-</span>    .doTry()
-        .process(<span class="code-keyword">new</span> ProcessorFail())
-        .to(<span class="code-quote">"mock:result"</span>)
-    <span class="code-comment">// <span class="code-keyword">catch</span> IOExcption that we <span class="code-keyword">do</span> not want to handle, eg the caller should get the error back
-</span>    .doCatch(IOException.class)
-        <span class="code-comment">// mark <span class="code-keyword">this</span> as NOT handled, eg the caller will also get the exception
-</span>        .handled(<span class="code-keyword">false</span>)
-        .to(<span class="code-quote">"mock:io"</span>)
-    .doCatch(Exception.class)
-        <span class="code-comment">// and <span class="code-keyword">catch</span> all other exceptions
-</span>        <span class="code-comment">// they are handled by <span class="code-keyword">default</span> (ie handled = <span class="code-keyword">true</span>)
-</span>        .to(<span class="code-quote">"mock:error"</span>)
-    <span class="code-comment">// here the <span class="code-keyword">try</span> block ends
-</span>    .end();
-</pre>
-</div></div>
+<div class="error"><span class="error">Unknown macro: {code}</span> 
+<p>from("direct:start")<br clear="none">
+    // here is our try where we try processing the exchange in the route below if it fails<br clear="none">
+    // we can catch it below, just like regular try .. catch .. finally in Java<br clear="none">
+    .doTry()<br clear="none">
+        .process(new ProcessorFail())<br clear="none">
+        .to("mock:result")<br clear="none">
+    // catch IOExcption that we do not want to handle, eg the caller should get the error back<br clear="none">
+    .doCatch(IOException.class)<br clear="none">
+        // mark this as NOT handled, eg the caller will also get the exception<br clear="none">
+        .handled(false)<br clear="none">
+        .to("mock:io")<br clear="none">
+    .doCatch(Exception.class)<br clear="none">
+        // and catch all other exceptions<br clear="none">
+        // they are handled by default (ie handled = true)<br clear="none">
+        .to("mock:error")<br clear="none">
+    // here the try block ends<br clear="none">
+    .end();</p></div>
 
 <p>And finally we have an example of the <tt>onWhen</tt> predicate in action. We can attach it to a <tt>doCatch</tt> 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 <b>damn</b> word.</p>
-<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">from(<span class="code-quote">"direct:start"</span>)
-    <span class="code-comment">// here is our <span class="code-keyword">try</span> where we <span class="code-keyword">try</span> processing the exchange in the route below <span class="code-keyword">if</span> it fails
-</span>    <span class="code-comment">// we can <span class="code-keyword">catch</span> it below, just like regular <span class="code-keyword">try</span> .. <span class="code-keyword">catch</span> .. <span class="code-keyword">finally</span> in Java
-</span>    .doTry()
-        .process(<span class="code-keyword">new</span> ProcessorFail())
-        .to(<span class="code-quote">"mock:result"</span>)
-    <span class="code-comment">// here we <span class="code-keyword">catch</span> the following 2 exceptions but only <span class="code-keyword">if</span>
-</span>    <span class="code-comment">// the onWhen predicate matches, eg <span class="code-keyword">if</span> the exception messsage
-</span>    <span class="code-comment">// conatins the string word Damn
-</span>    .doCatch(IOException.class, IllegalStateException.class)
-        .onWhen(exceptionMessage().contains(<span class="code-quote">"Damn"</span>))
-        .to(<span class="code-quote">"mock:<span class="code-keyword">catch</span>"</span>)
-    <span class="code-comment">// another <span class="code-keyword">catch</span> <span class="code-keyword">for</span> CamelExchangeException that does not have any onWhen predicate
-</span>    .doCatch(CamelExchangeException.class)
-        .to(<span class="code-quote">"mock:catchCamel"</span>)
-    <span class="code-comment">// and the <span class="code-keyword">finally</span> that is always processed
-</span>    .doFinally()
-        .to(<span class="code-quote">"mock:<span class="code-keyword">finally</span>"</span>)
-    <span class="code-comment">// here the <span class="code-keyword">try</span> block ends
-</span>    .end();
-</pre>
-</div></div>
+<div class="error"><span class="error">Unknown macro: {code}</span> 
+<p>from("direct:start")<br clear="none">
+    // here is our try where we try processing the exchange in the route below if it fails<br clear="none">
+    // we can catch it below, just like regular try .. catch .. finally in Java<br clear="none">
+    .doTry()<br clear="none">
+        .process(new ProcessorFail())<br clear="none">
+        .to("mock:result")<br clear="none">
+    // here we catch the following 2 exceptions but only if<br clear="none">
+    // the onWhen predicate matches, eg if the exception messsage<br clear="none">
+    // conatins the string word Damn<br clear="none">
+    .doCatch(IOException.class, IllegalStateException.class)<br clear="none">
+        .onWhen(exceptionMessage().contains("Damn"))<br clear="none">
+        .to("mock:catch")<br clear="none">
+    // another catch for CamelExchangeException that does not have any onWhen predicate<br clear="none">
+    .doCatch(CamelExchangeException.class)<br clear="none">
+        .to("mock:catchCamel")<br clear="none">
+    // and the finally that is always processed<br clear="none">
+    .doFinally()<br clear="none">
+        .to("mock:finally")<br clear="none">
+    // here the try block ends<br clear="none">
+    .end();</p></div>
 
 <h3><a shape="rect" name="TryCatchFinally-Usingtry..catch..finallyinSpringDSL"></a>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" title="Mock">Mock</a>.</p>
-<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-xml"><span class="code-tag">&lt;route&gt;</span>
-    <span class="code-tag">&lt;from uri=<span class="code-quote">"direct:start"</span>/&gt;</span>
-    <span class="code-tag"><span class="code-comment">&lt;!-- here the try starts. its a try .. catch .. finally just as regular java code --&gt;</span></span>
-    <span class="code-tag">&lt;doTry&gt;</span>
-        <span class="code-tag">&lt;process ref=<span class="code-quote">"processorFail"</span>/&gt;</span>
-        <span class="code-tag">&lt;to uri=<span class="code-quote">"mock:result"</span>/&gt;</span>
-        <span class="code-tag">&lt;doCatch&gt;</span>
-            <span class="code-tag"><span class="code-comment">&lt;!-- catch multiple exceptions --&gt;</span></span>
-            <span class="code-tag">&lt;exception&gt;</span>java.io.IOException<span class="code-tag">&lt;/exception&gt;</span>
-            <span class="code-tag">&lt;exception&gt;</span>java.lang.IllegalStateException<span class="code-tag">&lt;/exception&gt;</span>
-            <span class="code-tag">&lt;to uri=<span class="code-quote">"mock:catch"</span>/&gt;</span>
-        <span class="code-tag">&lt;/doCatch&gt;</span>
-        <span class="code-tag">&lt;doFinally&gt;</span>
-            <span class="code-tag">&lt;to uri=<span class="code-quote">"mock:finally"</span>/&gt;</span>
-        <span class="code-tag">&lt;/doFinally&gt;</span>
-    <span class="code-tag">&lt;/doTry&gt;</span>
-<span class="code-tag">&lt;/route&gt;</span>
-</pre>
-</div></div>
+<div class="error"><span class="error">Unknown macro: {code}</span> 
+<p>&lt;route&gt;<br clear="none">
+    &lt;from uri="direct:start"/&gt;<br clear="none">
+    &lt;!-- here the try starts. its a try .. catch .. finally just as regular java code --&gt;<br clear="none">
+    &lt;doTry&gt;<br clear="none">
+        &lt;process ref="processorFail"/&gt;<br clear="none">
+        &lt;to uri="mock:result"/&gt;<br clear="none">
+        &lt;doCatch&gt;<br clear="none">
+            &lt;!-- catch multiple exceptions --&gt;<br clear="none">
+            &lt;exception&gt;java.io.IOException&lt;/exception&gt;<br clear="none">
+            &lt;exception&gt;java.lang.IllegalStateException&lt;/exception&gt;<br clear="none">
+            &lt;to uri="mock:catch"/&gt;<br clear="none">
+        &lt;/doCatch&gt;<br clear="none">
+        &lt;doFinally&gt;<br clear="none">
+            &lt;to uri="mock:finally"/&gt;<br clear="none">
+        &lt;/doFinally&gt;<br clear="none">
+    &lt;/doTry&gt;<br clear="none">
+&lt;/route&gt;</p></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 <b>handled</b> 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 <tt>IOException</tt> as well.</p>
-<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-xml"><span class="code-tag">&lt;route&gt;</span>
-    <span class="code-tag">&lt;from uri=<span class="code-quote">"direct:start"</span>/&gt;</span>
-    <span class="code-tag"><span class="code-comment">&lt;!-- here the try starts. its a try .. catch .. finally just as regular java code --&gt;</span></span>
-    <span class="code-tag">&lt;doTry&gt;</span>
-        <span class="code-tag">&lt;process ref=<span class="code-quote">"processorFail"</span>/&gt;</span>
-        <span class="code-tag">&lt;to uri=<span class="code-quote">"mock:result"</span>/&gt;</span>
-        <span class="code-tag">&lt;doCatch&gt;</span>
-            <span class="code-tag"><span class="code-comment">&lt;!-- catch IOExcption that we do not want to handle, eg the caller should get the error back --&gt;</span></span>
-            <span class="code-tag">&lt;exception&gt;</span>java.io.IOException<span class="code-tag">&lt;/exception&gt;</span>
-            <span class="code-tag"><span class="code-comment">&lt;!-- mark this as NOT handled, eg the caller will also get the exception --&gt;</span></span>
-            <span class="code-tag">&lt;handled&gt;</span>
-                <span class="code-tag">&lt;constant&gt;</span>false<span class="code-tag">&lt;/constant&gt;</span>
-            <span class="code-tag">&lt;/handled&gt;</span>
-            <span class="code-tag">&lt;to uri=<span class="code-quote">"mock:io"</span>/&gt;</span>
-        <span class="code-tag">&lt;/doCatch&gt;</span>
-        <span class="code-tag">&lt;doCatch&gt;</span>
-            <span class="code-tag"><span class="code-comment">&lt;!-- and catch all other exceptions they are handled by default (ie handled = true) --&gt;</span></span>
-            <span class="code-tag">&lt;exception&gt;</span>java.lang.Exception<span class="code-tag">&lt;/exception&gt;</span>
-            <span class="code-tag">&lt;to uri=<span class="code-quote">"mock:error"</span>/&gt;</span>
-        <span class="code-tag">&lt;/doCatch&gt;</span>
-    <span class="code-tag">&lt;/doTry&gt;</span>
-<span class="code-tag">&lt;/route&gt;</span>
-</pre>
-</div></div>
+<div class="error"><span class="error">Unknown macro: {code}</span> 
+<p>&lt;route&gt;<br clear="none">
+    &lt;from uri="direct:start"/&gt;<br clear="none">
+    &lt;!-- here the try starts. its a try .. catch .. finally just as regular java code --&gt;<br clear="none">
+    &lt;doTry&gt;<br clear="none">
+        &lt;process ref="processorFail"/&gt;<br clear="none">
+        &lt;to uri="mock:result"/&gt;<br clear="none">
+        &lt;doCatch&gt;<br clear="none">
+            &lt;!-- catch IOExcption that we do not want to handle, eg the caller should get the error back --&gt;<br clear="none">
+            &lt;exception&gt;java.io.IOException&lt;/exception&gt;<br clear="none">
+            &lt;!-- mark this as NOT handled, eg the caller will also get the exception --&gt;<br clear="none">
+            &lt;handled&gt;<br clear="none">
+                &lt;constant&gt;false&lt;/constant&gt;<br clear="none">
+            &lt;/handled&gt;<br clear="none">
+            &lt;to uri="mock:io"/&gt;<br clear="none">
+        &lt;/doCatch&gt;<br clear="none">
+        &lt;doCatch&gt;<br clear="none">
+            &lt;!-- and catch all other exceptions they are handled by default (ie handled = true) --&gt;<br clear="none">
+            &lt;exception&gt;java.lang.Exception&lt;/exception&gt;<br clear="none">
+            &lt;to uri="mock:error"/&gt;<br clear="none">
+        &lt;/doCatch&gt;<br clear="none">
+    &lt;/doTry&gt;<br clear="none">
+&lt;/route&gt;</p></div>
 
 <p>And finally we have an example of the <tt>onWhen</tt> predicate in action. We can attach it to a <tt>doCatch</tt> 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 <b>damn</b> word.</p>
-<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-xml"><span class="code-tag">&lt;route&gt;</span>
-    <span class="code-tag">&lt;from uri=<span class="code-quote">"direct:start"</span>/&gt;</span>
-    <span class="code-tag"><span class="code-comment">&lt;!-- here the try starts. its a try .. catch .. finally just as regular java code --&gt;</span></span>
-    <span class="code-tag">&lt;doTry&gt;</span>
-        <span class="code-tag">&lt;process ref=<span class="code-quote">"processorFail"</span>/&gt;</span>
-        <span class="code-tag">&lt;to uri=<span class="code-quote">"mock:result"</span>/&gt;</span>
-        &lt;!-- here we catch the below 2 kind of exceptions but ONLY if the onWhen predicate matches
-             that means that the exception message should contain the string word 'Damn' --&gt;
-        <span class="code-tag">&lt;doCatch&gt;</span>
-            <span class="code-tag">&lt;exception&gt;</span>java.io.IOException<span class="code-tag">&lt;/exception&gt;</span>
-            <span class="code-tag">&lt;exception&gt;</span>java.lang.IllegalStateException<span class="code-tag">&lt;/exception&gt;</span>
-            <span class="code-tag">&lt;onWhen&gt;</span>
-                <span class="code-tag">&lt;simple&gt;</span>${exception.message} contains 'Damn'<span class="code-tag">&lt;/simple&gt;</span>
-            <span class="code-tag">&lt;/onWhen&gt;</span>
-            <span class="code-tag">&lt;to uri=<span class="code-quote">"mock:catch"</span>/&gt;</span>
-        <span class="code-tag">&lt;/doCatch&gt;</span>
-        <span class="code-tag"><span class="code-comment">&lt;!-- we can have multiple catch blocks for different exception and with their own onWhen --&gt;</span></span>
-        <span class="code-tag">&lt;doCatch&gt;</span>
-            <span class="code-tag">&lt;exception&gt;</span>org.apache.camel.CamelExchangeException<span class="code-tag">&lt;/exception&gt;</span>
-            <span class="code-tag">&lt;to uri=<span class="code-quote">"mock:catchCamel"</span>/&gt;</span>
-        <span class="code-tag">&lt;/doCatch&gt;</span>
-        <span class="code-tag"><span class="code-comment">&lt;!-- the finally is always processed --&gt;</span></span>
-        <span class="code-tag">&lt;doFinally&gt;</span>
-            <span class="code-tag">&lt;to uri=<span class="code-quote">"mock:finally"</span>/&gt;</span>
-        <span class="code-tag">&lt;/doFinally&gt;</span>
-    <span class="code-tag">&lt;/doTry&gt;</span>
-<span class="code-tag">&lt;/route&gt;</span>
-</pre>
-</div></div>
+<div class="error"><span class="error">Unknown macro: {code}</span> 
+<p>&lt;route&gt;<br clear="none">
+    &lt;from uri="direct:start"/&gt;<br clear="none">
+    &lt;!-- here the try starts. its a try .. catch .. finally just as regular java code --&gt;<br clear="none">
+    &lt;doTry&gt;<br clear="none">
+        &lt;process ref="processorFail"/&gt;<br clear="none">
+        &lt;to uri="mock:result"/&gt;<br clear="none">
+        &lt;!-- here we catch the below 2 kind of exceptions but ONLY if the onWhen predicate matches<br clear="none">
+             that means that the exception message should contain the string word 'Damn' --&gt;<br clear="none">
+        &lt;doCatch&gt;<br clear="none">
+            &lt;exception&gt;java.io.IOException&lt;/exception&gt;<br clear="none">
+            &lt;exception&gt;java.lang.IllegalStateException&lt;/exception&gt;<br clear="none">
+            &lt;onWhen&gt;<br clear="none">
+                &lt;simple&gt;$</p>
+<div class="error"><span class="error">Unknown macro: {exception.message}</span> </div>
+<p> contains 'Damn'&lt;/simple&gt;<br clear="none">
+            &lt;/onWhen&gt;<br clear="none">
+            &lt;to uri="mock:catch"/&gt;<br clear="none">
+        &lt;/doCatch&gt;<br clear="none">
+        &lt;!-- we can have multiple catch blocks for different exception and with their own onWhen --&gt;<br clear="none">
+        &lt;doCatch&gt;<br clear="none">
+            &lt;exception&gt;org.apache.camel.CamelExchangeException&lt;/exception&gt;<br clear="none">
+            &lt;to uri="mock:catchCamel"/&gt;<br clear="none">
+        &lt;/doCatch&gt;<br clear="none">
+        &lt;!-- the finally is always processed --&gt;<br clear="none">
+        &lt;doFinally&gt;<br clear="none">
+            &lt;to uri="mock:finally"/&gt;<br clear="none">
+        &lt;/doFinally&gt;<br clear="none">
+    &lt;/doTry&gt;<br clear="none">
+&lt;/route&gt;</p></div>
 
 <h3><a shape="rect" name="TryCatchFinally-SeeAlso"></a>See Also</h3>
 <ul class="alternate" type="square"><li><a shape="rect" href="error-handling-in-camel.html" title="Error handling in Camel">Error handling in Camel</a></li><li><a shape="rect" href="error-handler.html" title="Error Handler">Error Handler</a></li><li><a shape="rect" href="exception-clause.html" title="Exception Clause">Exception Clause</a></li></ul>
@@ -270,8 +262,8 @@ In our case we only want to trigger if t
 
 <h3><a shape="rect" name="Navigation-Search"></a>Search</h3>
 
-
-<form enctype="application/x-www-form-urlencoded" method="get" id="cse-search-box" action="http://www.google.com/cse">
+<p>
+</p><form enctype="application/x-www-form-urlencoded" method="get" id="cse-search-box" action="http://www.google.com/cse">
   <div>
     <input type="hidden" name="cx" value="007878419884033443453:m5nhvy4hmyq">
     <input type="hidden" name="ie" value="UTF-8">