Modified: websites/production/camel/content/file2.html ============================================================================== --- websites/production/camel/content/file2.html (original) +++ websites/production/camel/content/file2.html Wed Apr 18 16:20:42 2012 @@ -122,7 +122,7 @@ This option provides the build in strate <br clear="none" class="atl-forced-newline"> <tt>fileLock</tt> is for using <tt>java.nio.channels.FileLock</tt>. This option is <b>not</b> avail for the <a shape="rect" href="ftp2.html" title="FTP2">FTP</a> component. <br clear="none" class="atl-forced-newline"> <tt>rename</tt> is for using a try to rename the file as a test if we can get exclusive read-lock. <br clear="none" class="atl-forced-newline"> <tt>none</tt> is for no read locks at all.</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>readLockTimeout</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"><ul class="alternate" type="square"><li></li></ul> -</td><td colspan="1" rowspan="1" class="confluenceTd"> Optional timeout in millis for the read-lock, if supported by the read-lock. If the read-lock could not be granted and the timeout triggered, then Camel will skip the file. At next poll Camel, will try the file again, and this time maybe the read-lock could be granted. Use a value of 0 or lower to indicate forever. In <b>Camel 2.0</b> the default value is 0. In <b>Camel 2.1</b> the default value is 10000. Currently <tt>fileLock</tt>, <tt>changed</tt> and <tt>rename</tt> support the timeout. For <a shape="rect" href="ftp2.html" title="FTP2">FTP</a> the default <tt>readLockTimeout</tt> value is 20000. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>readLockCheckInterval</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>1000</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.6:</b> Interval in millis for the read-lock, if supported by the read lock. This interval is used for sleeping between attempts to acquire the read lock. For example when using the <tt>changed</tt> read lock, you can set a higher interval period to cater for <em>slow writes</em>. The default of 1 sec. may be <em>too fast</em> if the producer is very slow writing the file. For <a shape="rect" href="ftp2.html" title="FTP2">FTP</a> the default <tt>readLockCheckInterval</tt> is <tt>5000</tt>. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>directoryMustExist</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>false</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.5:</b> Similar to <tt>startingDirectoryMustExist</tt> but this applies during polling recursive sub directories. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>doneFileName</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>null</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.6:</b> If provided, Camel will only consume files if a <em>done</em> file exists. This option configures what file name to use. Either you can specify a fixed name. Or you can use dynamic placeholders. The <em>done</em> file is <b>always</b> expected in the same folder as the original file. See <em>using done file</em> and <em>writing done file</em> sections for examples. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>exclusiveReadLockStrategy</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>null</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> Pluggable read-lock as a <tt>org.apache.camel.component.file.GenericFileExclusiveReadLockStrategy</tt> implementation. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>maxMessagesPerPoll</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>0</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> An integer to define a maximum messages to gather per poll. By default no maximum is set. Can be used to set a limit of e.g. 1000 to avoid when starting up the server that there are thousands of files. Set a value of 0 or negative to disabled it. See more details at <a shape="rect" href="batch-consumer.html" title="Batch Consumer">Batch Consumer</a>. <b>Notice:</b> If this option is in use then the <a shape="rect" href="file2.html" title="File2">File</a> and <a shape="rect" href="ftp2.html" title="FTP2">FTP</a> components will limit <b>before</b> any sorting. For example if you have 100000 files and use <tt>maxMessagesPerPoll=500</tt>, then only the first 500 files will be picked up, and then sorted. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>minDepth</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> 0 </td><td colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.8</b>: The minimum depth to start processing when recursively processing a directory. Using <tt>minDepth=1</tt> means the base directory. Using <tt>minDepth=2</tt> means the first sub directory. This option is supported by <a shape="rect" href="ftp2.html" title="FTP2">FTP</a> consumer from <b>Camel 2.8.2, 2.9</b> onwards. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>maxDepth</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>Integer.MAX_VALUE</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.8:</b> The maximum depth to traverse when recursively processing a directory. This option is supported by <a shape="rect" href="ftp2.html" title="FTP2">FTP</a> consumer from <b>Camel 2.8.2, 2.9</b> onwards. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>processStrategy</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>null</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> A pluggable <tt>org.apache.camel.component.file.GenericFileProcessStrategy</tt> allowing you to implement your own <tt>readLock</tt> option or similar. Can also be used when spec ial conditions must be met before a file can be consumed, such as a special <em>ready</em> file exists. If this option is set then the <tt>readLock</tt> option does not apply. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>startingDirectoryMustExist</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>false</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.5:</b> Whether the starting directory must exist. Mind that the <tt>autoCreate</tt> option is default enabled, which means the starting directory is normally auto created if it doesn't exist. You can disable <tt>autoCreate</tt> and enable this to ensure the starting directory must exist. Will thrown an exception if the directory doesn't exist. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>pollStrategy</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>null</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.0:</b> A p luggable <tt>org.apache.camel.PollingConsumerPollStrategy</tt> allowing you to provide your custom implementation to control error handling usually occurred during the <tt>poll</tt> operation <b>before</b> an <a shape="rect" href="exchange.html" title="Exchange">Exchange</a> have been created and being routed in Camel. In other words the error occurred while the polling was gathering information, for instance access to a file network failed so Camel cannot access it to scan for files. The default implementation will log the caused exception at <tt>WARN</tt> level and ignore it. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>sendEmptyMessageWhenIdle</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>false</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.9:</b> If the polling consumer did not poll any files, you can enable this option to send an empty message (no body) instead. </td></tr></tbody></table> +</td><td colspan="1" rowspan="1" class="confluenceTd"> Optional timeout in millis for the read-lock, if supported by the read-lock. If the read-lock could not be granted and the timeout triggered, then Camel will skip the file. At next poll Camel, will try the file again, and this time maybe the read-lock could be granted. Use a value of 0 or lower to indicate forever. In <b>Camel 2.0</b> the default value is 0. In <b>Camel 2.1</b> the default value is 10000. Currently <tt>fileLock</tt>, <tt>changed</tt> and <tt>rename</tt> support the timeout. For <a shape="rect" href="ftp2.html" title="FTP2">FTP</a> the default <tt>readLockTimeout</tt> value is 20000. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>readLockCheckInterval</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>1000</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.6:</b> Interval in millis for the read-lock, if supported by the read lock. This interval is used for sleeping between attempts to acquire the read lock. For example when using the <tt>changed</tt> read lock, you can set a higher interval period to cater for <em>slow writes</em>. The default of 1 sec. may be <em>too fast</em> if the producer is very slow writing the file. For <a shape="rect" href="ftp2.html" title="FTP2">FTP</a> the default <tt>readLockCheckInterval</tt> is <tt>5000</tt>. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>directoryMustExist</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>false</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.5:</b> Similar to <tt>startingDirectoryMustExist</tt> but this applies during polling recursive sub directories. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>doneFileName</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>null</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.6:</b> If provided, Camel will only consume files if a <em>done</em> file exists. This option configures what file name to use. Either you can specify a fixed name. Or you can use dynamic placeholders. The <em>done</em> file is <b>always</b> expected in the same folder as the original file. See <em>using done file</em> and <em>writing done file</em> sections for examples. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>exclusiveReadLockStrategy</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>null</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> Pluggable read-lock as a <tt>org.apache.camel.component.file.GenericFileExclusiveReadLockStrategy</tt> implementation. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>maxMessagesPerPoll</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>0</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> An integer to define a maximum messages to gather per poll. By default no maximum is set. Can be used to set a limit of e.g. 1000 to avoid when starting up the server that there are thousands of files. Set a value of 0 or negative to disabled it. See more details at <a shape="rect" href="batch-consumer.html" title="Batch Consumer">Batch Consumer</a>. <b>Notice:</b> If this option is in use then the <a shape="rect" href="file2.html" title="File2">File</a> and <a shape="rect" href="ftp2.html" title="FTP2">FTP</a> components will limit <b>before</b> any sorting. For example if you have 100000 files and use <tt>maxMessagesPerPoll=500</tt>, then only the first 500 files will be picked up, and then sorted. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>minDepth</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> 0 </td><td colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.8</b>: The minimum depth to start processing when recursively processing a directory. Using <tt>minDepth=1</tt> means the base directory. Using <tt>minDepth=2</tt> means the first sub directory. This option is supported by <a shape="rect" href="ftp2.html" title="FTP2">FTP</a> consumer from <b>Camel 2.8.2, 2.9</b> onwards. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>maxDepth</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>Integer.MAX_VALUE</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.8:</b> The maximum depth to traverse when recursively processing a directory. This option is supported by <a shape="rect" href="ftp2.html" title="FTP2">FTP</a> consumer from <b>Camel 2.8.2, 2.9</b> onwards. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>processStrategy</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>null</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> A pluggable <tt>org.apache.camel.component.file.GenericFileProcessStrategy</tt> allowing you to implement your own <tt>readLock</tt> option or similar. Can also be used when spec ial conditions must be met before a file can be consumed, such as a special <em>ready</em> file exists. If this option is set then the <tt>readLock</tt> option does not apply. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>startingDirectoryMustExist</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>false</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.5:</b> Whether the starting directory must exist. Mind that the <tt>autoCreate</tt> option is default enabled, which means the starting directory is normally auto created if it doesn't exist. You can disable <tt>autoCreate</tt> and enable this to ensure the starting directory must exist. Will thrown an exception if the directory doesn't exist. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>pollStrategy</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>null</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.0:</b> A p luggable <tt>org.apache.camel.PollingConsumerPollStrategy</tt> allowing you to provide your custom implementation to control error handling usually occurred during the <tt>poll</tt> operation <b>before</b> an <a shape="rect" href="exchange.html" title="Exchange">Exchange</a> have been created and being routed in Camel. In other words the error occurred while the polling was gathering information, for instance access to a file network failed so Camel cannot access it to scan for files. The default implementation will log the caused exception at <tt>WARN</tt> level and ignore it. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>sendEmptyMessageWhenIdle</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>false</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.9:</b> If the polling consumer did not poll any files, you can enable this option to send an empty message (no body) instead. </td></tr><tr><td colspan="1" rowspan="1" cl ass="confluenceTd"> <tt>consumer.bridgeErrorHandler</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>false</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.10:</b> Allows to bridge the consumer to the Camel routing <a shape="rect" href="error-handler.html" title="Error Handler">Error Handler</a>, which mean any exceptions occurred while trying to pickup files, or the likes, will now be processed as a message and handled by the routing <a shape="rect" href="error-handler.html" title="Error Handler">Error Handler</a>. By default the consumer will use the <tt>org.apache.camel.spi.ExceptionHandler</tt> to deal with exceptions, that by default will be logged at WARN/ERROR level and ignored. See further below on this page fore more details, at section <em>How to use the Camel error handler to deal with exceptions triggered outside the routing engine</em>. </td></tr></tbody></table> </div> </div> @@ -808,6 +808,8 @@ to use that as a pluggable hook for end For the file and ftp components this would be the case. However if you want to bridge the <tt>ExceptionHandler</tt> so it uses the Camel <a shape="rect" href="error-handling-in-camel.html" title="Error handling in Camel">Error Handling</a>, then<br clear="none"> you need to implement a custom <tt>ExceptionHandler</tt> that will handle the exception by creating a Camel <a shape="rect" href="exchange.html" title="Exchange">Exchange</a> and send it to the routing engine; then the error handling of the routing engine can get triggered.</p> +<div class="panelMacro"><table class="tipMacro"><colgroup span="1"><col span="1" width="24"><col span="1"></colgroup><tr><td colspan="1" rowspan="1" valign="top"><img align="middle" src="https://cwiki.apache.org/confluence/images/icons/emoticons/check.gif" width="16" height="16" alt="" border="0"></td><td colspan="1" rowspan="1"><b>Easier with Camel 2.10</b><br clear="none">The new option consumer.bridgeErrorHandler can be set to true, to make this even easier. See further below</td></tr></table></div> + <p>Here is such an example based upon an unit test.</p> <p>First we have a custom <tt>ExceptionHandler</tt> where you can see we deal with the exception by sending it to a Camel <a shape="rect" href="endpoint.html" title="Endpoint">Endpoint</a> named "direct:file-error":</p> @@ -893,6 +895,36 @@ This is just for testing purpose. You ca <p>The source code for this example can be seen <a shape="rect" class="external-link" href="https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerCustomExceptionHandlerTest.java">here</a></p> +<h4><a shape="rect" name="File2-Usingconsumer.bridgeErrorHandler"></a>Using consumer.bridgeErrorHandler</h4> +<p><b>Available as of Camel 2.10</b></p> + +<p>If you want to use the Camel <a shape="rect" href="error-handler.html" title="Error Handler">Error Handler</a> to deal with any exception occurring in the file consumer, then you can enable the <tt>consumer.bridgeErrorHandler</tt> option as shown below:</p> +<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>Using consumer.bridgeErrorHandler</b></div><div class="codeContent panelContent"> +<pre class="code-java">@Override +<span class="code-keyword">protected</span> RouteBuilder createRouteBuilder() <span class="code-keyword">throws</span> Exception { + <span class="code-keyword">return</span> <span class="code-keyword">new</span> RouteBuilder() { + @Override + <span class="code-keyword">public</span> void configure() <span class="code-keyword">throws</span> Exception { + <span class="code-comment">// to handle any IOException being thrown +</span> onException(IOException.class) + .handled(<span class="code-keyword">true</span>) + .log(<span class="code-quote">"IOException occurred due: ${exception.message}"</span>) + .transform().simple(<span class="code-quote">"Error ${exception.message}"</span>) + .to(<span class="code-quote">"mock:error"</span>); + + <span class="code-comment">// <span class="code-keyword">this</span> is the file route that pickup files, notice how we bridge the consumer to use the Camel routing error handler +</span> <span class="code-comment">// the exclusiveReadLockStrategy is only configured because <span class="code-keyword">this</span> is from an unit test, so we use that to simulate exceptions +</span> from(<span class="code-quote">"file:target/nospace?exclusiveReadLockStrategy=#myReadLockStrategy&consumer.bridgeErrorHandler=<span class="code-keyword">true</span>"</span>) + .convertBodyTo(<span class="code-object">String</span>.class) + .to(<span class="code-quote">"mock:result"</span>); + } + }; +} +</pre> +</div></div> + +<p>So all you have to do is to enable this option, and the error handler in the route will take it from there.</p> + <h3><a shape="rect" name="File2-Debuglogging"></a>Debug logging</h3> <p>This component has log level <b>TRACE</b> that can be helpful if you have problems.</p>
Modified: websites/production/camel/content/transport.html ============================================================================== --- websites/production/camel/content/transport.html (original) +++ websites/production/camel/content/transport.html Wed Apr 18 16:20:42 2012 @@ -368,7 +368,12 @@ jmx://platform?options <pre class="code-xml"> jpa://entityName </pre> -</div></div> </td><td colspan="1" rowspan="1" class="confluenceTd"> For using a database as a queue via the JPA specification for working with <a shape="rect" class="external-link" href="http://openjpa.apache.org/">OpenJPA</a>, <a shape="rect" class="external-link" href="http://www.hibernate.org/" rel="nofollow">Hibernate</a> or TopLink </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <a shape="rect" href="jt400.html" title="JT400">JT/400 </a> / camel-jt400 +</div></div> </td><td colspan="1" rowspan="1" class="confluenceTd"> For using a database as a queue via the JPA specification for working with <a shape="rect" class="external-link" href="http://openjpa.apache.org/">OpenJPA</a>, <a shape="rect" class="external-link" href="http://www.hibernate.org/" rel="nofollow">Hibernate</a> or TopLink </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <a shape="rect" href="jsch.html" title="Jsch">Jsch</a> / camel-jsch +<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent"> +<pre class="code-xml"> +scp://localhost/destination +</pre> +</div></div> </td><td colspan="1" rowspan="1" class="confluenceTd"> Support for the scp protocol </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <a shape="rect" href="jt400.html" title="JT400">JT/400 </a> / camel-jt400 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent"> <pre class="code-xml"> jt400://user:pwd@system/<span class="code-tag"><path_to_dtaq></span> Modified: websites/production/camel/content/uris.html ============================================================================== --- websites/production/camel/content/uris.html (original) +++ websites/production/camel/content/uris.html Wed Apr 18 16:20:42 2012 @@ -366,7 +366,12 @@ jmx://platform?options <pre class="code-xml"> jpa://entityName </pre> -</div></div> </td><td colspan="1" rowspan="1" class="confluenceTd"> For using a database as a queue via the JPA specification for working with <a shape="rect" class="external-link" href="http://openjpa.apache.org/">OpenJPA</a>, <a shape="rect" class="external-link" href="http://www.hibernate.org/" rel="nofollow">Hibernate</a> or TopLink </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <a shape="rect" href="jt400.html" title="JT400">JT/400 </a> / camel-jt400 +</div></div> </td><td colspan="1" rowspan="1" class="confluenceTd"> For using a database as a queue via the JPA specification for working with <a shape="rect" class="external-link" href="http://openjpa.apache.org/">OpenJPA</a>, <a shape="rect" class="external-link" href="http://www.hibernate.org/" rel="nofollow">Hibernate</a> or TopLink </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <a shape="rect" href="jsch.html" title="Jsch">Jsch</a> / camel-jsch +<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent"> +<pre class="code-xml"> +scp://localhost/destination +</pre> +</div></div> </td><td colspan="1" rowspan="1" class="confluenceTd"> Support for the scp protocol </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <a shape="rect" href="jt400.html" title="JT400">JT/400 </a> / camel-jt400 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent"> <pre class="code-xml"> jt400://user:pwd@system/<span class="code-tag"><path_to_dtaq></span>