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 2014/01/17 09:19:46 UTC

svn commit: r894471 - in /websites/production/camel/content: cache/main.pageCache zip-file-dataformat.html

Author: buildbot
Date: Fri Jan 17 08:19:46 2014
New Revision: 894471

Log:
Production update by buildbot for camel

Modified:
    websites/production/camel/content/cache/main.pageCache
    websites/production/camel/content/zip-file-dataformat.html

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

Modified: websites/production/camel/content/zip-file-dataformat.html
==============================================================================
--- websites/production/camel/content/zip-file-dataformat.html (original)
+++ websites/production/camel/content/zip-file-dataformat.html Fri Jan 17 08:19:46 2014
@@ -85,54 +85,24 @@
 	<tbody>
         <tr>
         <td valign="top" width="100%">
-<div class="wiki-content maincontent"><h2 id="ZipFileDataFormat-ZipFile">Zip File</h2>
-
-    <div class="aui-message success shadowed information-macro">
+<div class="wiki-content maincontent"><h2 id="ZipFileDataFormat-ZipFile">Zip File</h2>    <div class="aui-message success shadowed information-macro">
                     <p class="title">Available since Camel 2.11.0</p>
                             <span class="aui-icon icon-success">Icon</span>
                 <div class="message-content">
                             &#160;
                     </div>
     </div>
-
-
-<p>The Zip File <a shape="rect" href="data-format.html">Data Format</a> is a message compression and de-compression format. Messages can be marshalled (compressed) to Zip files containing a single entry, and Zip files containing a single entry can be unmarshalled (decompressed) to the original file contents. This data format supports ZIP64, as long as <a shape="rect" class="external-link" href="https://blogs.oracle.com/xuemingshen/entry/zip64_support_for_4g_zipfile" rel="nofollow">Java 7 or later is being used</a>.</p>
-
-<h3 id="ZipFileDataFormat-Marshal">Marshal</h3>
-
-<p>In this example we marshal a regular text/XML payload to a compressed payload using Zip file compression, and send it to an ActiveMQ queue called MY_QUEUE.</p>
-
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<p>The Zip File <a shape="rect" href="data-format.html">Data Format</a> is a message compression and de-compression format. Messages can be marshalled (compressed) to Zip files containing a single entry, and Zip files containing a single entry can be unmarshalled (decompressed) to the original file contents. This data format supports ZIP64, as long as <a shape="rect" class="external-link" href="https://blogs.oracle.com/xuemingshen/entry/zip64_support_for_4g_zipfile" rel="nofollow">Java 7 or later is being used</a>.</p><p>Since Camel 2.13.3 there is also a aggregation strategy that can aggregate multiple messages into a single Zip file.</p><h3 id="ZipFileDataFormat-Marshal">Marshal</h3><p>In this example we marshal a regular text/XML payload to a compressed payload using Zip file compression, and send it to an ActiveMQ queue called MY_QUEUE.</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;).marshal().zipFile().to(&quot;activemq:queue:MY_QUEUE&quot;);]]></script>
-</div></div>
-
-<p>The name of the Zip entry inside the created Zip file is based on the incoming <code>CamelFileName</code> message header, which is the standard message header used by the <a shape="rect" href="file2.html">file component</a>. Additionally, the outgoing <code>CamelFileName</code> message header is automatically set to the value of the incoming <code>CamelFileName</code> message header, with the ".zip" suffix. So for example, if the following route finds a file named "test.txt" in the input directory, the output will be a Zip file named "test.txt.zip" containing a single Zip entry named "test.txt":</p>
-
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>The name of the Zip entry inside the created Zip file is based on the incoming <code>CamelFileName</code> message header, which is the standard message header used by the <a shape="rect" href="file2.html">file component</a>. Additionally, the outgoing <code>CamelFileName</code> message header is automatically set to the value of the incoming <code>CamelFileName</code> message header, with the ".zip" suffix. So for example, if the following route finds a file named "test.txt" in the input directory, the output will be a Zip file named "test.txt.zip" containing a single Zip entry named "test.txt":</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;file:input/directory?antInclude=*/.txt&quot;).marshal().zipFile().to(&quot;file:output/directory&quot;);]]></script>
-</div></div>
-
-<p>If there is no incoming <code>CamelFileName</code> message header (for example, if the <a shape="rect" href="file2.html">file component</a> is not the consumer), then the message ID is used by default, and since the message ID is normally a unique generated ID, you will end up with filenames like <code>ID-MACHINENAME-2443-1211718892437-1-0.zip</code>. If you want to override this behavior, then you can set the value of the <code>CamelFileName</code> header explicitly in your route:</p>
-
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>If there is no incoming <code>CamelFileName</code> message header (for example, if the <a shape="rect" href="file2.html">file component</a> is not the consumer), then the message ID is used by default, and since the message ID is normally a unique generated ID, you will end up with filenames like <code>ID-MACHINENAME-2443-1211718892437-1-0.zip</code>. If you want to override this behavior, then you can set the value of the <code>CamelFileName</code> header explicitly in your route:</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;).setHeader(Exchange.FILE_NAME, constant(&quot;report.txt&quot;)).marshal().zipFile().to(&quot;file:output/directory&quot;);]]></script>
-</div></div>
-
-<p>This route would result in a Zip file named "report.txt.zip" in the output directory, containing a single Zip entry named "report.txt".</p>
-
-<h3 id="ZipFileDataFormat-Unmarshal">Unmarshal</h3>
-
-<p>In this example we unmarshal a Zip file payload from an ActiveMQ queue called MY_QUEUE to its original format, and forward it for processing to the <code>UnZippedMessageProcessor</code>.</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;activemq:queue:MY_QUEUE&quot;).unmarshal().zipFile().process(new UnZippedMessageProcessor()); 
+</div></div><p>This route would result in a Zip file named "report.txt.zip" in the output directory, containing a single Zip entry named "report.txt".</p><h3 id="ZipFileDataFormat-Unmarshal">Unmarshal</h3><p>In this example we unmarshal a Zip file payload from an ActiveMQ queue called MY_QUEUE to its original format, and forward it for processing to the <code>UnZippedMessageProcessor</code>.</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;activemq:queue:MY_QUEUE&quot;).unmarshal().zipFile().process(new UnZippedMessageProcessor()); 
 ]]></script>
-</div></div>
-
-<p>If the zip file has more then one entry, the usingIterator option of ZipFileDataFormat to be true, and you can use splitter to do the further work.</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[
-  ZipFileDataFormat zipFile = new ZipFileDataFormat();
+</div></div><p>If the zip file has more then one entry, the usingIterator option of ZipFileDataFormat to be true, and you can use splitter to do the further work.</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[  ZipFileDataFormat zipFile = new ZipFileDataFormat();
   zipFile.setUsingIterator(true);
   from(&quot;file:src/test/resources/org/apache/camel/dataformat/zipfile/?consumer.delay=1000&amp;noop=true&quot;)
     .unmarshal(zipFile)
@@ -141,28 +111,43 @@ from(&quot;activemq:queue:MY_QUEUE&quot;
           .process(new UnZippedMessageProcessor())
     .end();
 ]]></script>
-</div></div>
-
-<p>Or you can use the ZipSplitter as an expression for splitter directly like this</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;file:src/test/resources/org/apache/camel/dataformat/zipfile?consumer.delay=1000&amp;noop=true&quot;)
+</div></div><p>Or you can use the ZipSplitter as an expression for splitter directly like this</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;file:src/test/resources/org/apache/camel/dataformat/zipfile?consumer.delay=1000&amp;noop=true&quot;)
      .split(new ZipSplitter())
         .streaming()
         .process(new UnZippedMessageProcessor())
      .end();
 ]]></script>
-</div></div>
-
-
-<h3 id="ZipFileDataFormat-Dependencies">Dependencies</h3>
-
-<p>To use Zip files in your camel routes you need to add a dependency on <strong>camel-zipfile</strong> which implements this data format.</p>
-
-<p>If you use Maven you can just add the following to your <code>pom.xml</code>, substituting the version number for the latest &amp; greatest release (see <a shape="rect" href="download.html">the download page for the latest versions</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;dependency&gt;
+</div></div><h3 id="ZipFileDataFormat-Aggregate">Aggregate</h3>    <div class="aui-message success shadowed information-macro">
+                    <p class="title">Available since Camel 2.12.3</p>
+                            <span class="aui-icon icon-success">Icon</span>
+                <div class="message-content">
+                            &#160;
+                    </div>
+    </div>
+<div>    <div class="aui-message hint shadowed information-macro">
+                            <span class="aui-icon icon-hint">Icon</span>
+                <div class="message-content">
+                            <p>Please note that this aggregation strategy requires eager completion check to work properly.</p>
+                    </div>
+    </div>
+<p>&#160;</p><p>In this example we aggregate all text files found in the input directory into a singel Zip file that is stored in the output directory.&#160;</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;file:input/directory?antInclude=*/.txt&quot;)
+     .aggregate(new ZipAggregationStrategy())
+       .constant(true)
+       .completionFromBatchConsumer()
+       .eagerCheckCompletion()
+   .to(&quot;file:output/directory&quot;);]]></script>
+</div></div><p>&#160;</p></div><div>The outgoing&#160;<code>CamelFileName</code>&#160;message header is created using &#160;java.io.File.createTempFile, with the ".zip" suffix.&#160;If you want to override this behavior, then you can set the value of the&#160;<code>CamelFileName</code>&#160;header explicitly in your route:</div><div><p>&#160;</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;file:input/directory?antInclude=*/.txt&quot;)
+     .aggregate(new ZipAggregationStrategy())
+       .constant(true)
+       .completionFromBatchConsumer()
+       .eagerCheckCompletion()
+     .setHeader(Exchange.FILE_NAME, constant(&quot;reports.zip&quot;))
+   .to(&quot;file:output/directory&quot;);]]></script>
+</div></div></div><h3 id="ZipFileDataFormat-Dependencies">Dependencies</h3><p>To use Zip files in your camel routes you need to add a dependency on <strong>camel-zipfile</strong> which implements this data format.</p><p>If you use Maven you can just add the following to your <code>pom.xml</code>, substituting the version number for the latest &amp; greatest release (see <a shape="rect" href="download.html">the download page for the latest versions</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;dependency&gt;
   &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
   &lt;artifactId&gt;camel-zipfile&lt;/artifactId&gt;
   &lt;version&gt;x.x.x&lt;/version&gt;