camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r828778 [2/2] - in /websites/production/camel/content: book-component-appendix.html book-in-one-page.html cache/main.pageCache file2.html
Date Mon, 13 Aug 2012 08:19:42 GMT
Modified: websites/production/camel/content/file2.html
==============================================================================
--- websites/production/camel/content/file2.html (original)
+++ websites/production/camel/content/file2.html Mon Aug 13 08:19:41 2012
@@ -82,14 +82,16 @@
 <h3><a shape="rect" name="File2-URIformat"></a>URI format</h3>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">file:directoryName[?options]
+<pre class="code-java">
+file:directoryName[?options]
 </pre>
 </div></div>
 
 <p>or</p>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">file:<span class="code-comment">//directoryName[?options]</span>
+<pre class="code-java">
+file:<span class="code-comment">//directoryName[?options]</span>
 </pre>
 </div></div>
 
@@ -125,7 +127,7 @@ Notice from <b>Camel 2.10</b> onwards th
 
 <h4><a shape="rect" name="File2-Producer"></a>Producer</h4>
 <div class="confluenceTableSmall"><div class="table-wrap">
-<table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"> Name </th><th colspan="1" rowspan="1" class="confluenceTh"> Default Value </th><th colspan="1" rowspan="1" class="confluenceTh"> Description </th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>fileExist</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>Override</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> What to do if a file already exists with the same name. The following values can be specified: <b>Override</b>, <b>Append</b>, <b>Fail</b> and <b>Ignore</b>. <tt>Override</tt>, which is the default, replaces the existing file. <tt>Append</tt> adds content to the existing file. <tt>Fail</tt> throws a <tt>GenericFileOperationException</tt>, indicating that there is already an existing file. <tt>Ignore</tt> silently ignores the problem and <b>does not</b> override the existing file, but assumes everything is okay. </td></tr><tr><td colspan="1
 " rowspan="1" class="confluenceTd"> <tt>tempPrefix</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>null</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> This option is used to write the file using a temporary name and then, after the write is complete, rename it to the real name. Can be used to identify files being written and also avoid consumers (not using exclusive read locks) reading in progress files. Is often used by <a shape="rect" href="ftp2.html" title="FTP2">FTP</a> when uploading big files. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>tempFileName</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>null</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.1:</b> The <b>same</b> as <tt>tempPrefix</tt> option but offering a more fine grained control on the naming of the temporary filename as it uses the <a shape="rect" href="file-language.html" title="File Language">File Language</a>. </
 td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>keepLastModified</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>false</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.2:</b> Will keep the last modified timestamp from the source file (if any). Will use the <tt>Exchange.FILE_LAST_MODIFIED</tt> header to located the timestamp. This header can contain either a <tt>java.util.Date</tt> or <tt>long</tt> with the timestamp. If the timestamp exists and the option is enabled it will set this timestamp on the written file. <b>Note:</b> This option only applies to the <b>file</b> producer. You <em>cannot</em> use this option with any of the ftp producers. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>eagerDeleteTargetFile</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>true</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.3:</b> Whether or not to eagerly delete any existi
 ng target file. This option only applies when you use <tt>fileExists=Override</tt> and the <tt>tempFileName</tt> option as well. You can use this to disable (set it to false) deleting the target file before the temp file is written. For example you may write big files and want the target file to exists during the temp file is being written. This ensure the target file is only deleted until the very last moment, just before the temp file is being renamed to the target filename. </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, then Camel will write a 2nd <em>done</em> file when the original file has been written. The <em>done</em> file will be empty. 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> fi
 le will <b>always</b> be written in the same folder as the original file. See <em>writing done file</em> section for examples. </td></tr></tbody></table>
+<table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"> Name </th><th colspan="1" rowspan="1" class="confluenceTh"> Default Value </th><th colspan="1" rowspan="1" class="confluenceTh"> Description </th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>fileExist</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>Override</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> What to do if a file already exists with the same name. The following values can be specified: <b>Override</b>, <b>Append</b>, <b>Fail</b> and <b>Ignore</b>. <tt>Override</tt>, which is the default, replaces the existing file. <tt>Append</tt> adds content to the existing file. <tt>Fail</tt> throws a <tt>GenericFileOperationException</tt>, indicating that there is already an existing file. <tt>Ignore</tt> silently ignores the problem and <b>does not</b> override the existing file, but assumes everything is okay. </td></tr><tr><td colspan="1
 " rowspan="1" class="confluenceTd"> <tt>tempPrefix</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>null</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> This option is used to write the file using a temporary name and then, after the write is complete, rename it to the real name. Can be used to identify files being written and also avoid consumers (not using exclusive read locks) reading in progress files. Is often used by <a shape="rect" href="ftp2.html" title="FTP2">FTP</a> when uploading big files. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>tempFileName</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>null</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.1:</b> The <b>same</b> as <tt>tempPrefix</tt> option but offering a more fine grained control on the naming of the temporary filename as it uses the <a shape="rect" href="file-language.html" title="File Language">File Language</a>. </
 td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>keepLastModified</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>false</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.2:</b> Will keep the last modified timestamp from the source file (if any). Will use the <tt>Exchange.FILE_LAST_MODIFIED</tt> header to located the timestamp. This header can contain either a <tt>java.util.Date</tt> or <tt>long</tt> with the timestamp. If the timestamp exists and the option is enabled it will set this timestamp on the written file. <b>Note:</b> This option only applies to the <b>file</b> producer. You <em>cannot</em> use this option with any of the ftp producers. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> <tt>eagerDeleteTargetFile</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>true</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.3:</b> Whether or not to eagerly delete any existi
 ng target file. This option only applies when you use <tt>fileExists=Override</tt> and the <tt>tempFileName</tt> option as well. You can use this to disable (set it to false) deleting the target file before the temp file is written. For example you may write big files and want the target file to exists during the temp file is being written. This ensure the target file is only deleted until the very last moment, just before the temp file is being renamed to the target filename. </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, then Camel will write a 2nd <em>done</em> file when the original file has been written. The <em>done</em> file will be empty. 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> fi
 le will <b>always</b> be written in the same folder as the original file. See <em>writing done file</em> section for examples. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><tt>allowNullBody</tt> </td><td colspan="1" rowspan="1" class="confluenceTd"> false </td><td colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.11:</b> Used to specify if a null body is allowed during file writing. If set to true then an empty file will be created, when set to false, and attempting to send a null body to the file component, a GenericFileWriteException of 'Cannot write null body to file.' will be thrown. If the `fileExist` option is set to 'Override', then the file will be truncated, and if set to `append` the file will remain unchanged</td></tr></tbody></table>
 </div>
 </div>
 
@@ -141,7 +143,8 @@ Notice from <b>Camel 2.10</b> onwards th
 
 <p>Lets illustrate this with an example:</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">    from(<span class="code-quote">"file:<span class="code-comment">//inbox?move=.done"</span>).to(<span class="code-quote">"bean:handleOrder"</span>);</span>
+<pre class="code-java">
+    from(<span class="code-quote">"file:<span class="code-comment">//inbox?move=.done"</span>).to(<span class="code-quote">"bean:handleOrder"</span>);</span>
 </pre>
 </div></div>
 <p>When a file is dropped in the <tt>inbox</tt> folder, the file consumer notices this and creates a new <tt>FileExchange</tt> that is routed to the <tt>handleOrder</tt> bean. The bean then processes the <tt>File</tt> object. At this point in time the file is still located in the <tt>inbox</tt> folder. After the bean completes, and thus the route is completed, the file consumer will perform the move operation and move the file to the <tt>.done</tt> sub-folder.</p>
@@ -152,19 +155,22 @@ Notice from <b>Camel 2.10</b> onwards th
 
 <p>If you want to delete the file after processing, the route should be:</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">    from(<span class="code-quote">"file:<span class="code-comment">//inobox?delete=<span class="code-keyword">true</span>"</span>).to(<span class="code-quote">"bean:handleOrder"</span>);</span>
+<pre class="code-java">
+    from(<span class="code-quote">"file:<span class="code-comment">//inobox?delete=<span class="code-keyword">true</span>"</span>).to(<span class="code-quote">"bean:handleOrder"</span>);</span>
 </pre>
 </div></div>
 
 <p>We have introduced a <b>pre</b> move operation to move files <b>before</b> they are processed. This allows you to mark which files have been scanned as they are moved to this sub folder before being processed.</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">    from(<span class="code-quote">"file:<span class="code-comment">//inbox?preMove=inprogress"</span>).to(<span class="code-quote">"bean:handleOrder"</span>);</span>
+<pre class="code-java">
+    from(<span class="code-quote">"file:<span class="code-comment">//inbox?preMove=inprogress"</span>).to(<span class="code-quote">"bean:handleOrder"</span>);</span>
 </pre>
 </div></div>
 
 <p>You can combine the <b>pre</b> move and the regular move:</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">    from(<span class="code-quote">"file:<span class="code-comment">//inbox?preMove=inprogress&amp;move=.done"</span>).to(<span class="code-quote">"bean:handleOrder"</span>);</span>
+<pre class="code-java">
+    from(<span class="code-quote">"file:<span class="code-comment">//inbox?preMove=inprogress&amp;move=.done"</span>).to(<span class="code-quote">"bean:handleOrder"</span>);</span>
 </pre>
 </div></div>
 <p>So in this situation, the file is in the <tt>inprogress</tt> folder when being processed and after it's processed, it's moved to the <tt>.done</tt> folder.</p>
@@ -176,7 +182,8 @@ Camel will, in fact, internally convert 
 
 <p>So if we want to move the file into a backup folder with today's date as the pattern, we can do:</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">move=backup/${date:now:yyyyMMdd}/${file:name}
+<pre class="code-java">
+move=backup/${date:now:yyyyMMdd}/${file:name}
 </pre>
 </div></div>
 
@@ -223,14 +230,16 @@ Camel will, in fact, internally convert 
 The charset option allows for configuring an encoding of the files on both the consumer and producer endpoints. For example if you read utf-8 files, and want to convert the files to iso-8859-1, you can do:</p>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">from(<span class="code-quote">"file:inbox?charset=utf-8"</span>)
+<pre class="code-java">
+from(<span class="code-quote">"file:inbox?charset=utf-8"</span>)
   .to(<span class="code-quote">"file:outbox?charset=iso-8859-1"</span>)
 </pre>
 </div></div>
 
 <p>You can also use the <tt>convertBodyTo</tt> in the route. In the example below we have still input files in utf-8 format, but we want to convert the file content to a byte array in iso-8859-1 format. And then let a bean process the data. Before writing the content to the outbox folder using the current charset.</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">from(<span class="code-quote">"file:inbox?charset=utf-8"</span>)
+<pre class="code-java">
+from(<span class="code-quote">"file:inbox?charset=utf-8"</span>)
   .convertBodyTo(<span class="code-object">byte</span>[].class, <span class="code-quote">"iso-8859-1"</span>)
   .to(<span class="code-quote">"bean:myBean"</span>)
   .to(<span class="code-quote">"file:outbox"</span>);
@@ -242,7 +251,8 @@ The charset option allows for configurin
 <p>In the example below this could be a problem if the files is not in UTF-8 encoding, which would be the default encoding for read the files.<br clear="none">
 In this example when writing the files, the content has already been converted to a byte array, and thus would write the content directly as is (without any further encodings).</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">from(<span class="code-quote">"file:inbox"</span>)
+<pre class="code-java">
+from(<span class="code-quote">"file:inbox"</span>)
   .convertBodyTo(<span class="code-object">byte</span>[].class, <span class="code-quote">"iso-8859-1"</span>)
   .to(<span class="code-quote">"bean:myBean"</span>)
   .to(<span class="code-quote">"file:outbox"</span>);
@@ -251,7 +261,8 @@ In this example when writing the files, 
 
 <p>You can also override and control the encoding dynamic when writing files, by setting a property on the exchange with the key <tt>Exchange.CHARSET_NAME</tt>. For example in the route below we set the property with a value from a message header.</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">from(<span class="code-quote">"file:inbox"</span>)
+<pre class="code-java">
+from(<span class="code-quote">"file:inbox"</span>)
   .convertBodyTo(<span class="code-object">byte</span>[].class, <span class="code-quote">"iso-8859-1"</span>)
   .to(<span class="code-quote">"bean:myBean"</span>)
   .setProperty(Exchange.CHARSET_NAME, header(<span class="code-quote">"someCharsetHeader"</span>))
@@ -266,13 +277,15 @@ In this example when writing the files, 
 <p>If you have some issues then you can enable DEBUG logging on <tt>org.apache.camel.component.file</tt>, and Camel logs when it reads/write a file using a specific charset.<br clear="none">
 For example the route below will log the following:</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">from(<span class="code-quote">"file:inbox?charset=utf-8"</span>)
+<pre class="code-java">
+from(<span class="code-quote">"file:inbox?charset=utf-8"</span>)
   .to(<span class="code-quote">"file:outbox?charset=iso-8859-1"</span>)
 </pre>
 </div></div>
 <p>And the logs:</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">DEBUG GenericFileConverter           - Read file /Users/davsclaus/workspace/camel/camel-core/target/charset/input/input.txt with charset utf-8
+<pre class="code-java">
+DEBUG GenericFileConverter           - Read file /Users/davsclaus/workspace/camel/camel-core/target/charset/input/input.txt with charset utf-8
 DEBUG FileOperations                 - Using Reader to write file: target/charset/output.txt with charset: iso-8859-1
 </pre>
 </div></div>
@@ -283,22 +296,26 @@ DEBUG FileOperations                 - U
 
 <p>The sample code below produces files using the message ID as the filename:</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">from(<span class="code-quote">"direct:report"</span>).to(<span class="code-quote">"file:target/reports"</span>);
+<pre class="code-java">
+from(<span class="code-quote">"direct:report"</span>).to(<span class="code-quote">"file:target/reports"</span>);
 </pre>
 </div></div>
 <p>To use <tt>report.txt</tt> as the filename you have to do:</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">from(<span class="code-quote">"direct:report"</span>).setHeader(Exchange.FILE_NAME, constant(<span class="code-quote">"report.txt"</span>)).to( <span class="code-quote">"file:target/reports"</span>);
+<pre class="code-java">
+from(<span class="code-quote">"direct:report"</span>).setHeader(Exchange.FILE_NAME, constant(<span class="code-quote">"report.txt"</span>)).to( <span class="code-quote">"file:target/reports"</span>);
 </pre>
 </div></div>
 <p>... the same as above, but with <tt>CamelFileName</tt>:</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">from(<span class="code-quote">"direct:report"</span>).setHeader(<span class="code-quote">"CamelFileName"</span>, constant(<span class="code-quote">"report.txt"</span>)).to( <span class="code-quote">"file:target/reports"</span>);
+<pre class="code-java">
+from(<span class="code-quote">"direct:report"</span>).setHeader(<span class="code-quote">"CamelFileName"</span>, constant(<span class="code-quote">"report.txt"</span>)).to( <span class="code-quote">"file:target/reports"</span>);
 </pre>
 </div></div>
 <p>And a syntax where we set the filename on the endpoint with the <b>fileName</b> URI option.</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">from(<span class="code-quote">"direct:report"</span>).to(<span class="code-quote">"file:target/reports/?fileName=report.txt"</span>);
+<pre class="code-java">
+from(<span class="code-quote">"direct:report"</span>).to(<span class="code-quote">"file:target/reports/?fileName=report.txt"</span>);
 </pre>
 </div></div>
 
@@ -319,7 +336,8 @@ DEBUG FileOperations                 - U
 
 <p>If you want only to consume files when a done file exists, then you can use the <tt>doneFileName</tt> option on the endpoint.</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">from(<span class="code-quote">"file:bar?doneFileName=done"</span>);
+<pre class="code-java">
+from(<span class="code-quote">"file:bar?doneFileName=done"</span>);
 </pre>
 </div></div>
 <p>Will only consume files from the bar folder, if a file name done exists in the same directory as the target files. Camel will automatically delete the done file when it's done consuming the files. From Camel <b>2.9.3</b> onwards Camel will not automatic delete the done file if <tt>noop=true</tt> is configured.</p>
@@ -327,7 +345,8 @@ DEBUG FileOperations                 - U
 <p>However its more common to have one done file per target file. This means there is a 1:1 correlation. To do this you must use dynamic placeholders in the <tt>doneFileName</tt> option. Currently Camel supports the following two dynamic tokens: <tt><a shape="rect" class="external-link" href="file:name" rel="nofollow">file:name</a></tt> and <tt><a shape="rect" class="external-link" href="file:name.noext" rel="nofollow">file:name.noext</a></tt> which must be enclosed in ${ }. The consumer only supports the static part of the done file name as either prefix or suffix (not both).</p>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">from(<span class="code-quote">"file:bar?doneFileName=${file:name}.done"</span>);
+<pre class="code-java">
+from(<span class="code-quote">"file:bar?doneFileName=${file:name}.done"</span>);
 </pre>
 </div></div>
 
@@ -337,7 +356,8 @@ DEBUG FileOperations                 - U
 
 <p>You can also use a prefix for the done file, such as:</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">from(<span class="code-quote">"file:bar?doneFileName=ready-${file:name}"</span>);
+<pre class="code-java">
+from(<span class="code-quote">"file:bar?doneFileName=ready-${file:name}"</span>);
 </pre>
 </div></div>
 <ul class="alternate" type="square"><li><tt>hello.txt</tt> - is the file to be consumed</li><li><tt>ready-hello.txt</tt> - is the associated done file</li></ul>
@@ -351,7 +371,8 @@ DEBUG FileOperations                 - U
 
 <p>After you have written af file you may want to write an additional <em>done</em> file as a kinda of marker, to indicate to others that the file is finished and has been written. To do that you can use the <tt>doneFileName</tt> option on the file producer endpoint.</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">.to(<span class="code-quote">"file:bar?doneFileName=done"</span>);
+<pre class="code-java">
+.to(<span class="code-quote">"file:bar?doneFileName=done"</span>);
 </pre>
 </div></div>
 <p>Will simply create a file named <tt>done</tt> in the same directory as the target file.</p>
@@ -359,19 +380,22 @@ DEBUG FileOperations                 - U
 <p>However its more common to have one done file per target file. This means there is a 1:1 correlation. To do this you must use dynamic placeholders in the <tt>doneFileName</tt> option. Currently Camel supports the following two dynamic tokens: <tt><a shape="rect" class="external-link" href="file:name" rel="nofollow">file:name</a></tt> and <tt><a shape="rect" class="external-link" href="file:name.noext" rel="nofollow">file:name.noext</a></tt> which must be enclosed in ${ }.</p>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">.to(<span class="code-quote">"file:bar?doneFileName=done-${file:name}"</span>);
+<pre class="code-java">
+.to(<span class="code-quote">"file:bar?doneFileName=done-${file:name}"</span>);
 </pre>
 </div></div>
 <p>Will for example create a file named <tt>done-foo.txt</tt> if the target file was <tt>foo.txt</tt> in the same directory as the target file.</p>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">.to(<span class="code-quote">"file:bar?doneFileName=${file:name}.done"</span>);
+<pre class="code-java">
+.to(<span class="code-quote">"file:bar?doneFileName=${file:name}.done"</span>);
 </pre>
 </div></div>
 <p>Will for example create a file named <tt>foo.txt.done</tt> if the target file was <tt>foo.txt</tt> in the same directory as the target file.</p>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">.to(<span class="code-quote">"file:bar?doneFileName=${file:name.noext}.done"</span>);
+<pre class="code-java">
+.to(<span class="code-quote">"file:bar?doneFileName=${file:name.noext}.done"</span>);
 </pre>
 </div></div>
 <p>Will for example create a file named <tt>foo.done</tt> if the target file was <tt>foo.txt</tt> in the same directory as the target file.</p>
@@ -381,7 +405,8 @@ DEBUG FileOperations                 - U
 <h4><a shape="rect" name="File2-Readfromadirectoryandwritetoanotherdirectory"></a>Read from a directory and write to another directory</h4>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">from(<span class="code-quote">"file:<span class="code-comment">//inputdir/?delete=<span class="code-keyword">true</span>"</span>).to(<span class="code-quote">"file://outputdir"</span>)</span>
+<pre class="code-java">
+from(<span class="code-quote">"file:<span class="code-comment">//inputdir/?delete=<span class="code-keyword">true</span>"</span>).to(<span class="code-quote">"file://outputdir"</span>)</span>
 </pre>
 </div></div>
 
@@ -389,19 +414,22 @@ DEBUG FileOperations                 - U
 
 <h4><a shape="rect" name="File2-Readingrecursivelyfromadirectoryandwritingtoanother"></a>Reading recursively from a directory and writing to another</h4>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">from(<span class="code-quote">"file:<span class="code-comment">//inputdir/?recursive=<span class="code-keyword">true</span>&amp;delete=<span class="code-keyword">true</span>"</span>).to(<span class="code-quote">"file://outputdir"</span>)</span>
+<pre class="code-java">
+from(<span class="code-quote">"file:<span class="code-comment">//inputdir/?recursive=<span class="code-keyword">true</span>&amp;delete=<span class="code-keyword">true</span>"</span>).to(<span class="code-quote">"file://outputdir"</span>)</span>
 </pre>
 </div></div>
 
 <p>Listen on a directory and create a message for each file dropped there. Copy the contents to the <tt>outputdir</tt> and delete the file in the <tt>inputdir</tt>. Will scan recursively into sub-directories. Will lay out the files in the same directory structure in the <tt>outputdir</tt> as the <tt>inputdir</tt>, including any sub-directories.</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">inputdir/foo.txt
+<pre class="code-java">
+inputdir/foo.txt
 inputdir/sub/bar.txt
 </pre>
 </div></div>
 <p>Will result in the following output layout:</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">outputdir/foo.txt
+<pre class="code-java">
+outputdir/foo.txt
 outputdir/sub/bar.txt
 </pre>
 </div></div>
@@ -410,12 +438,14 @@ outputdir/sub/bar.txt
 
 <p>If you want to store the files in the outputdir directory in the same directory, disregarding the source directory layout (e.g. to flatten out the path), you just add the <tt>flatten=true</tt> option on the file producer side:</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">from(<span class="code-quote">"file:<span class="code-comment">//inputdir/?recursive=<span class="code-keyword">true</span>&amp;delete=<span class="code-keyword">true</span>"</span>).to(<span class="code-quote">"file://outputdir?flatten=<span class="code-keyword">true</span>"</span>)</span>
+<pre class="code-java">
+from(<span class="code-quote">"file:<span class="code-comment">//inputdir/?recursive=<span class="code-keyword">true</span>&amp;delete=<span class="code-keyword">true</span>"</span>).to(<span class="code-quote">"file://outputdir?flatten=<span class="code-keyword">true</span>"</span>)</span>
 </pre>
 </div></div>
 <p>Will result in the following output layout:</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">outputdir/foo.txt
+<pre class="code-java">
+outputdir/foo.txt
 outputdir/bar.txt
 </pre>
 </div></div>
@@ -424,20 +454,23 @@ outputdir/bar.txt
 
 <p>Camel will by default move any processed file into a <tt>.camel</tt> subdirectory in the directory the file was consumed from.</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">from(<span class="code-quote">"file:<span class="code-comment">//inputdir/?recursive=<span class="code-keyword">true</span>&amp;delete=<span class="code-keyword">true</span>"</span>).to(<span class="code-quote">"file://outputdir"</span>)</span>
+<pre class="code-java">
+from(<span class="code-quote">"file:<span class="code-comment">//inputdir/?recursive=<span class="code-keyword">true</span>&amp;delete=<span class="code-keyword">true</span>"</span>).to(<span class="code-quote">"file://outputdir"</span>)</span>
 </pre>
 </div></div>
 <p>Affects the layout as follows:<br clear="none">
 <b>before</b></p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">inputdir/foo.txt
+<pre class="code-java">
+inputdir/foo.txt
 inputdir/sub/bar.txt
 </pre>
 </div></div>
 
 <p><b>after</b></p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">inputdir/.camel/foo.txt
+<pre class="code-java">
+inputdir/.camel/foo.txt
 inputdir/sub/.camel/bar.txt
 outputdir/foo.txt
 outputdir/sub/bar.txt
@@ -447,7 +480,8 @@ outputdir/sub/bar.txt
 <h4><a shape="rect" name="File2-Readfromadirectoryandprocessthemessageinjava"></a>Read from a directory and process the message in java</h4>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">from(<span class="code-quote">"file:<span class="code-comment">//inputdir/"</span>).process(<span class="code-keyword">new</span> Processor() {
+<pre class="code-java">
+from(<span class="code-quote">"file:<span class="code-comment">//inputdir/"</span>).process(<span class="code-keyword">new</span> Processor() {
 </span>  <span class="code-keyword">public</span> void process(Exchange exchange) <span class="code-keyword">throws</span> Exception {
     <span class="code-object">Object</span> body = exchange.getIn().getBody();
     <span class="code-comment">// <span class="code-keyword">do</span> some business logic with the input body
@@ -511,7 +545,8 @@ outputdir/sub/bar.txt
 
 <p>Using a single route, it is possible to write a file to any number of subdirectories. If you have a route setup as such:</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">  &lt;route&gt;
+<pre class="code-java">
+  &lt;route&gt;
     &lt;from uri=<span class="code-quote">"bean:myBean"</span>/&gt;
     &lt;to uri=<span class="code-quote">"file:/rootDirectory"</span>/&gt;
   &lt;/route&gt;
@@ -520,7 +555,8 @@ outputdir/sub/bar.txt
 
 <p>You can have <tt>myBean</tt> set the header <tt>Exchange.FILE_NAME</tt> to values such as:</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">Exchange.FILE_NAME = hello.txt =&gt; /rootDirectory/hello.txt
+<pre class="code-java">
+Exchange.FILE_NAME = hello.txt =&gt; /rootDirectory/hello.txt
 Exchange.FILE_NAME = foo/bye.txt =&gt; /rootDirectory/foo/bye.txt
 </pre>
 </div></div>
@@ -531,7 +567,8 @@ Exchange.FILE_NAME = foo/bye.txt =&gt; /
 
 <p>In this sample we want to move consumed files to a backup folder using today's date as a sub-folder name:</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">from(<span class="code-quote">"file:<span class="code-comment">//inbox?move=backup/${date:now:yyyyMMdd}/${file:name}"</span>).to(<span class="code-quote">"..."</span>);</span>
+<pre class="code-java">
+from(<span class="code-quote">"file:<span class="code-comment">//inbox?move=backup/${date:now:yyyyMMdd}/${file:name}"</span>).to(<span class="code-quote">"..."</span>);</span>
 </pre>
 </div></div>
 
@@ -541,13 +578,15 @@ Exchange.FILE_NAME = foo/bye.txt =&gt; /
 
 <p>Camel supports <a shape="rect" href="idempotent-consumer.html" title="Idempotent Consumer">Idempotent Consumer</a> directly within the component so it will skip already processed files. This feature can be enabled by setting the <tt>idempotent=true</tt> option.</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">from(<span class="code-quote">"file:<span class="code-comment">//inbox?idempotent=<span class="code-keyword">true</span>"</span>).to(<span class="code-quote">"..."</span>);</span>
+<pre class="code-java">
+from(<span class="code-quote">"file:<span class="code-comment">//inbox?idempotent=<span class="code-keyword">true</span>"</span>).to(<span class="code-quote">"..."</span>);</span>
 </pre>
 </div></div>
 
 <p>By default Camel uses a in memory based store for keeping track of consumed files, it uses a least recently used cache holding up to 1000 entries. You can plugin your own implementation of this store by using the <tt>idempotentRepository</tt> option using the <tt>#</tt> sign in the value to indicate it's a referring to a bean in the <a shape="rect" href="registry.html" title="Registry">Registry</a> with the specified <tt>id</tt>.</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-xml">   <span class="code-tag"><span class="code-comment">&lt;!-- define our store as a plain spring bean --&gt;</span></span>
+<pre class="code-xml">
+   <span class="code-tag"><span class="code-comment">&lt;!-- define our store as a plain spring bean --&gt;</span></span>
    <span class="code-tag">&lt;bean id=<span class="code-quote">"myStore"</span> class=<span class="code-quote">"com.mycompany.MyIdempotentStore"</span>/&gt;</span>
 
   <span class="code-tag">&lt;route&gt;</span>
@@ -559,7 +598,8 @@ Exchange.FILE_NAME = foo/bye.txt =&gt; /
 
 <p>Camel will log at <tt>DEBUG</tt> level if it skips a file because it has been consumed before:</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">DEBUG FileConsumer is idempotent and the file has been consumed before. Will skip <span class="code-keyword">this</span> file: target\idempotent\report.txt
+<pre class="code-java">
+DEBUG FileConsumer is idempotent and the file has been consumed before. Will skip <span class="code-keyword">this</span> file: target\idempotent\report.txt
 </pre>
 </div></div>
 
@@ -640,7 +680,8 @@ This repository uses a 1st level cache t
 
 <p>And yes then we just need to refer to the <b>jpaStore</b> bean in the file consumer endpoint using the <tt>idempotentRepository</tt> using the <tt>#</tt> syntax option:</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>
+<pre class="code-xml">
+  <span class="code-tag">&lt;route&gt;</span>
     <span class="code-tag">&lt;from uri=<span class="code-quote">"file://inbox?idempotent=true&amp;amp;idempotentRepository=#jpaStore"</span>/&gt;</span>
     <span class="code-tag">&lt;to uri=<span class="code-quote">"bean:processInbox"</span>/&gt;</span>
   <span class="code-tag">&lt;/route&gt;</span>
@@ -668,7 +709,8 @@ This repository uses a 1st level cache t
 
 <p>And then we can configure our route using the <b>filter</b> attribute to reference our filter (using <tt>#</tt> notation) that we have defined in the spring XML file:</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-xml">   <span class="code-tag"><span class="code-comment">&lt;!-- define our sorter as a plain spring bean --&gt;</span></span>
+<pre class="code-xml">
+   <span class="code-tag"><span class="code-comment">&lt;!-- define our sorter as a plain spring bean --&gt;</span></span>
    <span class="code-tag">&lt;bean id=<span class="code-quote">"myFilter"</span> class=<span class="code-quote">"com.mycompany.MyFileSorter"</span>/&gt;</span>
 
   <span class="code-tag">&lt;route&gt;</span>
@@ -728,7 +770,8 @@ The reasons is that we leverage Spring's
 
 <p>And then we can configure our route using the <b>sorter</b> option to reference to our sorter (<tt>mySorter</tt>) we have defined in the spring XML file:</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-xml">   <span class="code-tag"><span class="code-comment">&lt;!-- define our sorter as a plain spring bean --&gt;</span></span>
+<pre class="code-xml">
+   <span class="code-tag"><span class="code-comment">&lt;!-- define our sorter as a plain spring bean --&gt;</span></span>
    <span class="code-tag">&lt;bean id=<span class="code-quote">"mySorter"</span> class=<span class="code-quote">"com.mycompany.MyFileSorter"</span>/&gt;</span>
 
   <span class="code-tag">&lt;route&gt;</span>
@@ -744,55 +787,65 @@ The reasons is that we leverage Spring's
 
 <p>Camel supports pluggable sorting strategies. This strategy it to use the <a shape="rect" href="file-language.html" title="File Language">File Language</a> to configure the sorting. The <tt>sortBy</tt> option is configured as follows:</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">sortBy=group 1;group 2;group 3;...
+<pre class="code-java">
+sortBy=group 1;group 2;group 3;...
 </pre>
 </div></div>
 <p>Where each group is separated with semi colon. In the simple situations you just use one group, so a simple example could be:</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">sortBy=file:name
+<pre class="code-java">
+sortBy=file:name
 </pre>
 </div></div>
 <p>This will sort by file name, you can reverse the order by prefixing <tt>reverse:</tt> to the group, so the sorting is now Z..A:</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">sortBy=reverse:file:name
+<pre class="code-java">
+sortBy=reverse:file:name
 </pre>
 </div></div>
 <p>As we have the full power of <a shape="rect" href="file-language.html" title="File Language">File Language</a> we can use some of the other parameters, so if we want to sort by file size we do:</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">sortBy=file:length
+<pre class="code-java">
+sortBy=file:length
 </pre>
 </div></div>
 
 <p>You can configure to ignore the case, using <tt>ignoreCase:</tt> for string comparison, so if you want to use file name sorting but to ignore the case then we do:</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">sortBy=ignoreCase:file:name
+<pre class="code-java">
+sortBy=ignoreCase:file:name
 </pre>
 </div></div>
 <p>You can combine ignore case and reverse, however reverse must be specified first:</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">sortBy=reverse:ignoreCase:file:name
+<pre class="code-java">
+sortBy=reverse:ignoreCase:file:name
 </pre>
 </div></div>
 
 <p>In the sample below we want to sort by last modified file, so we do:</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">sortBy=file:modifed
+<pre class="code-java">
+sortBy=file:modifed
 </pre>
 </div></div>
 <p>And then we want to group by name as a 2nd option so files with same modifcation is sorted by name:</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">sortBy=file:modifed;file:name
+<pre class="code-java">
+sortBy=file:modifed;file:name
 </pre>
 </div></div>
 <p>Now there is an issue here, can you spot it? Well the modified timestamp of the file is too fine as it will be in milliseconds, but what if we want to sort by date only and then subgroup by name?<br clear="none">
 Well as we have the true power of <a shape="rect" href="file-language.html" title="File Language">File Language</a> we can use the its date command that supports patterns. So this can be solved as:</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">sortBy=date:file:yyyyMMdd;file:name
+<pre class="code-java">
+sortBy=date:file:yyyyMMdd;file:name
 </pre>
 </div></div>
 <p>Yeah, that is pretty powerful, oh by the way you can also use reverse per group, so we could reverse the file names:</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">sortBy=date:file:yyyyMMdd;reverse:file:name
+<pre class="code-java">
+sortBy=date:file:yyyyMMdd;reverse:file:name
 </pre>
 </div></div>
 



Mime
View raw message