Author: buildbot Date: Thu Oct 1 08:21:05 2015 New Revision: 967388 Log: Production update by buildbot for camel
Modified: websites/production/camel/content/book-in-one-page.html websites/production/camel/content/book-pattern-appendix.html websites/production/camel/content/cache/main.pageCache websites/production/camel/content/resequencer.html Modified: websites/production/camel/content/book-in-one-page.html ============================================================================== --- websites/production/camel/content/book-in-one-page.html (original) +++ websites/production/camel/content/book-in-one-page.html Thu Oct 1 08:21:05 2015 @@ -3696,11 +3696,11 @@ The tutorial has been designed in two pa While not actual tutorials you might find working through the source of the various <a shape="rect" href="examples.html">Examples</a> useful.</li></ul> <h2 id="BookInOnePage-TutorialonSpringRemotingwithJMS">Tutorial on Spring Remoting with JMS</h2><p> </p><div class="confluence-information-macro confluence-information-macro-information"><p class="title">Thanks</p><span class="aui-icon aui-icon-small aui-iconfont-info confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>This tutorial was kindly donated to Apache Camel by Martin Gilday.</p></div></div><h2 id="BookInOnePage-Preface">Preface</h2><p>This tutorial aims to guide the reader through the stages of creating a project which uses Camel to facilitate the routing of messages from a JMS queue to a <a shape="rect" class="external-link" href="http://www.springramework.org" rel="nofollow">Spring</a> service. The route works in a synchronous fashion returning a response to the client.</p><p><style type="text/css">/*<![CDATA[*/ -div.rbtoc1443511149698 {padding: 0px;} -div.rbtoc1443511149698 ul {list-style: disc;margin-left: 0px;} -div.rbtoc1443511149698 li {margin-left: 0px;padding-left: 0px;} +div.rbtoc1443687534414 {padding: 0px;} +div.rbtoc1443687534414 ul {list-style: disc;margin-left: 0px;} +div.rbtoc1443687534414 li {margin-left: 0px;padding-left: 0px;} -/*]]>*/</style></p><div class="toc-macro rbtoc1443511149698"> +/*]]>*/</style></p><div class="toc-macro rbtoc1443687534414"> <ul class="toc-indentation"><li><a shape="rect" href="#BookInOnePage-TutorialonSpringRemotingwithJMS">Tutorial on Spring Remoting with JMS</a></li><li><a shape="rect" href="#BookInOnePage-Preface">Preface</a></li><li><a shape="rect" href="#BookInOnePage-Prerequisites">Prerequisites</a></li><li><a shape="rect" href="#BookInOnePage-Distribution">Distribution</a></li><li><a shape="rect" href="#BookInOnePage-About">About</a></li><li><a shape="rect" href="#BookInOnePage-CreatetheCamelProject">Create the Camel Project</a> <ul class="toc-indentation"><li><a shape="rect" href="#BookInOnePage-UpdatethePOMwithDependencies">Update the POM with Dependencies</a></li></ul> </li><li><a shape="rect" href="#BookInOnePage-WritingtheServer">Writing the Server</a> @@ -5805,11 +5805,11 @@ So we completed the last piece in the pi <p>This example has been removed from <strong>Camel 2.9</strong> onwards. Apache Axis 1.4 is a very old and unsupported framework. We encourage users to use <a shape="rect" href="cxf.html">CXF</a> instead of Axis.</p></div></div> <style type="text/css">/*<![CDATA[*/ -div.rbtoc1443511149991 {padding: 0px;} -div.rbtoc1443511149991 ul {list-style: disc;margin-left: 0px;} -div.rbtoc1443511149991 li {margin-left: 0px;padding-left: 0px;} +div.rbtoc1443687535081 {padding: 0px;} +div.rbtoc1443687535081 ul {list-style: disc;margin-left: 0px;} +div.rbtoc1443687535081 li {margin-left: 0px;padding-left: 0px;} -/*]]>*/</style><div class="toc-macro rbtoc1443511149991"> +/*]]>*/</style><div class="toc-macro rbtoc1443687535081"> <ul class="toc-indentation"><li><a shape="rect" href="#BookInOnePage-TutorialusingAxis1.4withApacheCamel">Tutorial using Axis 1.4 with Apache Camel</a> <ul class="toc-indentation"><li><a shape="rect" href="#BookInOnePage-Prerequisites">Prerequisites</a></li><li><a shape="rect" href="#BookInOnePage-Distribution">Distribution</a></li><li><a shape="rect" href="#BookInOnePage-Introduction">Introduction</a></li><li><a shape="rect" href="#BookInOnePage-SettinguptheprojecttorunAxis">Setting up the project to run Axis</a> <ul class="toc-indentation"><li><a shape="rect" href="#BookInOnePage-Maven2">Maven 2</a></li><li><a shape="rect" href="#BookInOnePage-wsdl">wsdl</a></li><li><a shape="rect" href="#BookInOnePage-ConfiguringAxis">Configuring Axis</a></li><li><a shape="rect" href="#BookInOnePage-RunningtheExample">Running the Example</a></li></ul> @@ -13701,85 +13701,32 @@ from("direct:start") } ]]></script> </div></div><p>Notice that the return type is a List which we want to contain the user names. The 1st parameter is the list of names, and then notice the 2nd parameter is the incoming <code>com.foo.User</code> type.</p><h3 id="BookInOnePage-Seealso.1">See also</h3><ul class="alternate"><li>The <a shape="rect" href="loan-broker-example.html">Loan Broker Example</a> which uses an aggregator</li><li><a shape="rect" class="external-link" href="http://tmielke.blogspot.com/2009/01/using-camel-aggregator-correctly.html" rel="nofollow">Blog post by Torsten Mielke</a> about using the aggregator correctly.</li><li>The old <a shape="rect" href="aggregator.html">Aggregator</a></li><li><a shape="rect" href="hawtdb.html">HawtDB</a>, <a shape="rect" href="leveldb.html">LevelDB</a> or <a shape="rect" href="sql-component.html">SQL Component</a> for persistence support</li><li><a shape="rect" href="aggregate-example.html">Aggregate Example</a> for an example application</li></ul> -<h3 id="BookInOnePage-Resequencer">Resequencer</h3> - -<p>The <a shape="rect" class="external-link" href="http://www.enterpriseintegrationpatterns.com/Resequencer.html" rel="nofollow">Resequencer</a> from the <a shape="rect" href="enterprise-integration-patterns.html">EIP patterns</a> allows you to reorganise messages based on some comparator. By default in Camel we use an <a shape="rect" href="expression.html">Expression</a> to create the comparator; so that you can compare by a message header or the body or a piece of a message etc.</p> - -<p><span class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image confluence-external-resource" src="http://www.enterpriseintegrationpatterns.com/img/Resequencer.gif" data-image-src="http://www.enterpriseintegrationpatterns.com/img/Resequencer.gif"></span></p> - -<div class="confluence-information-macro confluence-information-macro-tip"><p class="title">Change in Camel 2.7</p><span class="aui-icon aui-icon-small aui-iconfont-approve confluence-information-macro-icon"></span><div class="confluence-information-macro-body"> -<p>The <code><batch-config></code> and <code><stream-config></code> tags in XML DSL in the Resequencer EIP must now be configured in the top, and not in the bottom. So if you use those, then move them up just below the <code><resequence></code> EIP starts in the XML. If you are using Camel older than 2.7, then those configs should be at the bottom.</p></div></div> - -<p>Camel supports two resequencing algorithms:</p> - -<ul><li><strong>Batch resequencing</strong> collects messages into a batch, sorts the messages and sends them to their output.</li><li><strong>Stream resequencing</strong> re-orders (continuous) message streams based on the detection of gaps between messages.</li></ul> - - -<p>By default the <a shape="rect" href="resequencer.html">Resequencer</a> does not support duplicate messages and will only keep the last message, in case a message arrives with the same message expression. However in the batch mode you can enable it to allow duplicates.</p> - -<h3 id="BookInOnePage-BatchResequencing">Batch Resequencing</h3> - -<p>The following example shows how to use the batch-processing resequencer so that messages are sorted in order of the <strong>body()</strong> expression. That is messages are collected into a batch (either by a maximum number of messages per batch or using a timeout) then they are sorted in order and then sent out to their output.</p> - -<p><strong>Using the <a shape="rect" href="fluent-builders.html">Fluent Builders</a></strong></p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<h3 id="BookInOnePage-Resequencer">Resequencer</h3><p>The <a shape="rect" class="external-link" href="http://www.enterpriseintegrationpatterns.com/Resequencer.html" rel="nofollow">Resequencer</a> from the <a shape="rect" href="enterprise-integration-patterns.html">EIP patterns</a> allows you to reorganise messages based on some comparator. By default in Camel we use an <a shape="rect" href="expression.html">Expression</a> to create the comparator; so that you can compare by a message header or the body or a piece of a message etc.</p><p><span class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image confluence-external-resource" src="http://www.enterpriseintegrationpatterns.com/img/Resequencer.gif" data-image-src="http://www.enterpriseintegrationpatterns.com/img/Resequencer.gif"></span></p><div class="confluence-information-macro confluence-information-macro-tip"><p class="title">Change in Camel 2.7</p><span class="aui-icon aui-icon-small aui-iconfont-approve co nfluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>The <code><batch-config></code> and <code><stream-config></code> tags in XML DSL in the Resequencer EIP must now be configured in the top, and not in the bottom. So if you use those, then move them up just below the <code><resequence></code> EIP starts in the XML. If you are using Camel older than 2.7, then those configs should be at the bottom.</p></div></div><p>Camel supports two resequencing algorithms:</p><ul><li><strong>Batch resequencing</strong> collects messages into a batch, sorts the messages and sends them to their output.</li><li><strong>Stream resequencing</strong> re-orders (continuous) message streams based on the detection of gaps between messages.</li></ul><p>By default the <a shape="rect" href="resequencer.html">Resequencer</a> does not support duplicate messages and will only keep the last message, in case a message arrives with the same message expression. However in the batch mode you can enable it to allow duplicates.</p><h3 id="BookInOnePage-BatchResequencing">Batch Resequencing</h3><p>The following example shows how to use the batch-processing resequencer so that messages are sorted in order of the <strong>body()</strong> expression. That is messages are collected into a batch (either by a maximum number of messages per batch or using a timeout) then they are sorted in order and then sent out to their output.</p><p><strong>Using the <a shape="rect" href="fluent-builders.html">Fluent Builders</a></strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ from("direct:start") .resequence().body() .to("mock:result"); ]]></script> -</div></div> - -<p>This is equvalent to </p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ -from("direct:start") +</div></div>This is equivalent to<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from("direct:start") .resequence(body()).batch() .to("mock:result"); ]]></script> -</div></div> - -<p>The batch-processing resequencer can be further configured via the <code>size()</code> and <code>timeout()</code> methods.</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ -from("direct:start") +</div></div><p>The batch-processing resequencer can be further configured via the <code>size()</code> and <code>timeout()</code> methods.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from("direct:start") .resequence(body()).batch().size(300).timeout(4000L) .to("mock:result") ]]></script> -</div></div> - -<p>This sets the batch size to 300 and the batch timeout to 4000 ms (by default, the batch size is 100 and the timeout is 1000 ms). Alternatively, you can provide a configuration object.</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ -from("direct:start") +</div></div><p>This sets the batch size to 300 and the batch timeout to 4000 ms (by default, the batch size is 100 and the timeout is 1000 ms). Alternatively, you can provide a configuration object.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from("direct:start") .resequence(body()).batch(new BatchResequencerConfig(300, 4000L)) .to("mock:result") ]]></script> -</div></div> - - -<p>So the above example will reorder messages from endpoint <strong>direct:a</strong> in order of their bodies, to the endpoint <strong>mock:result</strong>. <br clear="none"> -Typically you'd use a header rather than the body to order things; or maybe a part of the body. So you could replace this expression with</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ -resequencer(header("mySeqNo")) +</div></div><p>So the above example will reorder messages from endpoint <strong>direct:a</strong> in order of their bodies, to the endpoint <strong>mock:result</strong>. <br clear="none"> Typically you'd use a header rather than the body to order things; or maybe a part of the body. So you could replace this expression with</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[resequencer(header("mySeqNo")) ]]></script> -</div></div> - -<p>for example to reorder messages using a custom sequence number in the header <code>mySeqNo</code>.</p> - -<p>You can of course use many different <a shape="rect" href="expression.html">Expression</a> languages such as <a shape="rect" href="xpath.html">XPath</a>, <a shape="rect" href="xquery.html">XQuery</a>, <a shape="rect" href="sql.html">SQL</a> or various <a shape="rect" href="scripting-languages.html">Scripting Languages</a>.</p> - -<p><strong>Using the <a shape="rect" href="spring-xml-extensions.html">Spring XML Extensions</a></strong></p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ -<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> +</div></div><p>for example to reorder messages using a custom sequence number in the header <code>mySeqNo</code>.</p><p>You can of course use many different <a shape="rect" href="expression.html">Expression</a> languages such as <a shape="rect" href="xpath.html">XPath</a>, <a shape="rect" href="xquery.html">XQuery</a>, <a shape="rect" href="sql.html">SQL</a> or various <a shape="rect" href="scripting-languages.html">Scripting Languages</a>.</p><p><strong>Using the <a shape="rect" href="spring-xml-extensions.html">Spring XML Extensions</a></strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="direct:start" /> <resequence> @@ -13793,26 +13740,7 @@ resequencer(header("mySeqNo")) </route> </camelContext> ]]></script> -</div></div> - -<h4 id="BookInOnePage-AllowDuplicates">Allow Duplicates</h4> -<p><strong>Available as of Camel 2.4</strong></p> - -<p>In the <code>batch</code> mode, you can now allow duplicates. In Java DSL there is a <code>allowDuplicates()</code> method and in Spring XML there is an <code>allowDuplicates=true</code> attribute on the <code><batch-config/></code> you can use to enable it.</p> - -<h4 id="BookInOnePage-Reverse">Reverse</h4> -<p><strong>Available as of Camel 2.4</strong></p> - -<p>In the <code>batch</code> mode, you can now reverse the expression ordering. By default the order is based on 0..9,A..Z, which would let messages with low numbers be ordered first, and thus also also outgoing first. In some cases you want to reverse order, which is now possible.</p> - -<p>In Java DSL there is a <code>reverse()</code> method and in Spring XML there is an <code>reverse=true</code> attribute on the <code><batch-config/></code> you can use to enable it.</p> - -<h4 id="BookInOnePage-ResequenceJMSmessagesbasedonJMSPriority">Resequence JMS messages based on JMSPriority</h4> -<p><strong>Available as of Camel 2.4</strong></p> - -<p>It's now much easier to use the <a shape="rect" href="resequencer.html">Resequencer</a> to resequence messages from <a shape="rect" href="jms.html">JMS</a> queues based on <code>JMSPriority</code>. For that to work you need to use the two new options <code>allowDuplicates</code> and <code>reverse</code>. </p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><h4 id="BookInOnePage-AllowDuplicates">Allow Duplicates</h4><p><strong>Available as of Camel 2.4</strong></p><p>In the <code>batch</code> mode, you can now allow duplicates. In Java DSL there is a <code>allowDuplicates()</code> method and in Spring XML there is an <code>allowDuplicates=true</code> attribute on the <code><batch-config/></code> you can use to enable it.</p><h4 id="BookInOnePage-Reverse">Reverse</h4><p><strong>Available as of Camel 2.4</strong></p><p>In the <code>batch</code> mode, you can now reverse the expression ordering. By default the order is based on 0..9,A..Z, which would let messages with low numbers be ordered first, and thus also also outgoing first. In some cases you want to reverse order, which is now possible.</p><p>In Java DSL there is a <code>reverse()</code> method and in Spring XML there is an <code>reverse=true</code> attribute on the <code><batch-config/></code> you can use to enable it.</p><h4 id="BookInOnePage-ResequenceJM SmessagesbasedonJMSPriority">Resequence JMS messages based on JMSPriority</h4><p><strong>Available as of Camel 2.4</strong></p><p>It's now much easier to use the <a shape="rect" href="resequencer.html">Resequencer</a> to resequence messages from <a shape="rect" href="jms.html">JMS</a> queues based on <code>JMSPriority</code>. For that to work you need to use the two new options <code>allowDuplicates</code> and <code>reverse</code>.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ from("jms:queue:foo") // sort by JMSPriority by allowing duplicates (message can have same JMSPriority) @@ -13821,16 +13749,7 @@ from("jms:queue:foo") .resequence(header("JMSPriority")).batch().timeout(3000).allowDuplicates().reverse() .to("mock:result"); ]]></script> -</div></div> - -<p>Notice this is <strong>only</strong> possible in the <code>batch</code> mode of the <a shape="rect" href="resequencer.html">Resequencer</a>.</p> - -<h4 id="BookInOnePage-Ignoreinvalidexchanges">Ignore invalid exchanges</h4> -<p><strong>Available as of Camel 2.9</strong></p> - -<p>The <a shape="rect" href="resequencer.html">resequencer</a> EIP will from Camel 2.9 onwards throw a <code>CamelExchangeException</code> if the incoming <a shape="rect" href="exchange.html">Exchange</a> is not valid for the resequencer - ie. the expression cannot be evaluated, such as a missing header. You can use the option <code>ignoreInvalidExchanges</code> to ignore these exceptions which means the <a shape="rect" href="resequencer.html">Resequencer</a> will then skip the invalid <a shape="rect" href="exchange.html">Exchange</a>.</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div>Notice this is <strong>only</strong> possible in the <code>batch</code> mode of the <a shape="rect" href="resequencer.html">Resequencer</a>.<h4 id="BookInOnePage-Ignoreinvalidexchanges">Ignore invalid exchanges</h4><p><strong>Available as of Camel 2.9</strong></p><p>The <a shape="rect" href="resequencer.html">Resequencer</a> EIP will from Camel 2.9 onwards throw a <code>CamelExchangeException</code> if the incoming <a shape="rect" href="exchange.html">Exchange</a> is not valid for the resequencer - ie. the expression cannot be evaluated, such as a missing header. You can use the option <code>ignoreInvalidExchanges</code> to ignore these exceptions which means the <a shape="rect" href="resequencer.html">Resequencer</a> will then skip the invalid <a shape="rect" href="exchange.html">Exchange</a>.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ from("direct:start") .resequence(header("seqno")).batch().timeout(1000) @@ -13838,65 +13757,27 @@ from("direct:start") .ignoreInvalidExchanges() .to("mock:result"); ]]></script> -</div></div> - -<p>This option is available for both batch and stream resequencer.</p> - -<h4 id="BookInOnePage-RejectOldExchanges">Reject Old Exchanges</h4> -<p><strong>Available as of Camel 2.11</strong></p> - -<p>This option can be used to prevent out of order messages from being sent regardless of the event that delivered messages downstream (capacity, timeout, etc). If enabled using <code>rejectOld()</code>, the <a shape="rect" href="resequencer.html">Resequencer</a> will throw a <code>MessageRejectedException</code> when an incoming <a shape="rect" href="exchange.html">Exchange</a> is "older" (based on the Comparator) than the last delivered message. This provides an extra level of control with regards to delayed message ordering. </p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ -from("direct:start") +</div></div>This option is available for both batch and stream resequencer.<h4 id="BookInOnePage-RejectOldExchanges">Reject Old Exchanges</h4><p><strong>Available as of Camel 2.11</strong></p><p>This option can be used to prevent out of order messages from being sent regardless of the event that delivered messages downstream (capacity, timeout, etc). If enabled using <code>rejectOld()</code>, the <a shape="rect" href="resequencer.html">Resequencer</a> will throw a <code>MessageRejectedException</code> when an incoming <a shape="rect" href="exchange.html">Exchange</a> is "older" (based on the Comparator) than the last delivered message. This provides an extra level of control with regards to delayed message ordering.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from("direct:start") .onException(MessageRejectedException.class).handled(true).to("mock:error").end() .resequence(header("seqno")).stream().timeout(1000).rejectOld() .to("mock:result"); ]]></script> -</div></div> - -<p>This option is available for the stream resequencer only.</p> - -<h3 id="BookInOnePage-StreamResequencing">Stream Resequencing</h3> - -<p>The next example shows how to use the stream-processing resequencer. Messages are re-ordered based on their sequence numbers given by a <code>seqnum</code> header using gap detection and timeouts on the level of individual messages. </p> - -<p><strong>Using the <a shape="rect" href="fluent-builders.html">Fluent Builders</a></strong></p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><p>This option is available for the stream resequencer only.</p><h3 id="BookInOnePage-StreamResequencing">Stream Resequencing</h3><p>The next example shows how to use the stream-processing resequencer. Messages are re-ordered based on their sequence numbers given by a <code>seqnum</code> header using gap detection and timeouts on the level of individual messages.</p><p><strong>Using the <a shape="rect" href="fluent-builders.html">Fluent Builders</a></strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ from("direct:start").resequence(header("seqnum")).stream().to("mock:result"); ]]></script> -</div></div> - -<p>The stream-processing resequencer can be further configured via the <code>capacity()</code> and <code>timeout()</code> methods.</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ -from("direct:start") +</div></div>The stream-processing resequencer can be further configured via the <code>capacity()</code> and <code>timeout()</code> methods.<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from("direct:start") .resequence(header("seqnum")).stream().capacity(5000).timeout(4000L) .to("mock:result") ]]></script> -</div></div> - -<p>This sets the resequencer's capacity to 5000 and the timeout to 4000 ms (by default, the capacity is 1000 and the timeout is 1000 ms). Alternatively, you can provide a configuration object.</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ -from("direct:start") +</div></div><p>This sets the resequencer's capacity to 5000 and the timeout to 4000 ms (by default, the capacity is 1000 and the timeout is 1000 ms). Alternatively, you can provide a configuration object.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from("direct:start") .resequence(header("seqnum")).stream(new StreamResequencerConfig(5000, 4000L)) .to("mock:result") ]]></script> -</div></div> - -<p>The stream-processing resequencer algorithm is based on the detection of gaps in a message stream rather than on a fixed batch size. Gap detection in combination with timeouts removes the constraint of having to know the number of messages of a sequence (i.e. the batch size) in advance. Messages must contain a unique sequence number for which a predecessor and a successor is known. For example a message with the sequence number 3 has a predecessor message with the sequence number 2 and a successor message with the sequence number 4. The message sequence 2,3,5 has a gap because the sucessor of 3 is missing. The resequencer therefore has to retain message 5 until message 4 arrives (or a timeout occurs). </p> - -<p>If the maximum time difference between messages (with successor/predecessor relationship with respect to the sequence number) in a message stream is known, then the resequencer's timeout parameter should be set to this value. In this case it is guaranteed that all messages of a stream are delivered in correct order to the next processor. The lower the timeout value is compared to the out-of-sequence time difference the higher is the probability for out-of-sequence messages delivered by this resequencer. Large timeout values should be supported by sufficiently high capacity values. The capacity parameter is used to prevent the resequencer from running out of memory. </p> - -<p>By default, the stream resequencer expects <code>long</code> sequence numbers but other sequence numbers types can be supported as well by providing a custom expression.</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><p>The stream-processing resequencer algorithm is based on the detection of gaps in a message stream rather than on a fixed batch size. Gap detection in combination with timeouts removes the constraint of having to know the number of messages of a sequence (i.e. the batch size) in advance. Messages must contain a unique sequence number for which a predecessor and a successor is known. For example a message with the sequence number 3 has a predecessor message with the sequence number 2 and a successor message with the sequence number 4. The message sequence 2,3,5 has a gap because the successor of 3 is missing. The resequencer therefore has to retain message 5 until message 4 arrives (or a timeout occurs).</p><p>If the maximum time difference between messages (with successor/predecessor relationship with respect to the sequence number) in a message stream is known, then the resequencer's timeout parameter should be set to this value. In this case it is guaranteed that all messages of a stream are delivered in correct order to the next processor. The lower the timeout value is compared to the out-of-sequence time difference the higher is the probability for out-of-sequence messages delivered by this resequencer. Large timeout values should be supported by sufficiently high capacity values. The capacity parameter is used to prevent the resequencer from running out of memory.</p><p>By default, the stream resequencer expects <code>long</code> sequence numbers but other sequence numbers types can be supported as well by providing a custom expression.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ public class MyFileNameExpression implements Expression { @@ -13920,44 +13801,26 @@ public class MyFileNameExpression implem } ]]></script> -</div></div> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ from("direct:start").resequence(new MyFileNameExpression()).stream().timeout(100).to("mock:result"); ]]></script> -</div></div> - -<p>or custom comparator via the <code>comparator()</code> method</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ -ExpressionResultComparator<Exchange> comparator = new MyComparator(); +</div></div>or custom comparator via the <code>comparator()</code> method<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ExpressionResultComparator<Exchange> comparator = new MyComparator(); from("direct:start") .resequence(header("seqnum")).stream().comparator(comparator) .to("mock:result"); ]]></script> -</div></div> - -<p>or via a <code>StreamResequencerConfig</code> object.</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ -ExpressionResultComparator<Exchange> comparator = new MyComparator(); +</div></div><p>or via a <code>StreamResequencerConfig</code> object.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ExpressionResultComparator<Exchange> comparator = new MyComparator(); StreamResequencerConfig config = new StreamResequencerConfig(100, 1000L, comparator); from("direct:start") .resequence(header("seqnum")).stream(config) .to("mock:result"); ]]></script> -</div></div> - - -<p><strong>Using the <a shape="rect" href="spring-xml-extensions.html">Spring XML Extensions</a></strong></p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ -<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> +</div></div><p><strong>Using the <a shape="rect" href="spring-xml-extensions.html">Spring XML Extensions</a></strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="direct:start"/> <resequence> @@ -13968,13 +13831,7 @@ from("direct:start") </route> </camelContext> ]]></script> -</div></div> - -<h3 id="BookInOnePage-FurtherExamples">Further Examples</h3> - -<p>For further examples of this pattern in use you could look at the <a shape="rect" class="external-link" href="http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ResequencerTest.java?view=markup">batch-processing resequencer junit test case</a> and the <a shape="rect" class="external-link" href="http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/StreamResequencerTest.java?view=markup">stream-processing resequencer junit test case</a></p> - -<h4 id="BookInOnePage-UsingThisPattern.20">Using This Pattern</h4> +</div></div><h3 id="BookInOnePage-FurtherExamples">Further Examples</h3><p>For further examples of this pattern in use you could look at the <a shape="rect" class="external-link" href="http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ResequencerTest.java?view=markup">batch-processing resequencer junit test case</a> and the <a shape="rect" class="external-link" href="http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/StreamResequencerTest.java?view=markup">stream-processing resequencer junit test case</a></p><p></p><h4 id="BookInOnePage-UsingThisPattern.20">Using This Pattern</h4> <p>If you would like to use this EIP Pattern then please read the <a shape="rect" href="getting-started.html">Getting Started</a>, you may also find the <a shape="rect" href="architecture.html">Architecture</a> useful particularly the description of <a shape="rect" href="endpoint.html">Endpoint</a> and <a shape="rect" href="uris.html">URIs</a>. Then you could try out some of the <a shape="rect" href="examples.html">Examples</a> first before trying this pattern out.</p> <h3 id="BookInOnePage-ComposedMessageProcessor">Composed Message Processor</h3> @@ -17565,11 +17422,11 @@ template.send("direct:alias-verify& ]]></script> </div></div><p></p><h3 id="BookInOnePage-SeeAlso.28">See Also</h3> <ul><li><a shape="rect" href="configuring-camel.html">Configuring Camel</a></li><li><a shape="rect" href="component.html">Component</a></li><li><a shape="rect" href="endpoint.html">Endpoint</a></li><li><a shape="rect" href="getting-started.html">Getting Started</a></li></ul><ul><li><a shape="rect" href="crypto.html">Crypto</a> Crypto is also available as a <a shape="rect" href="data-format.html">Data Format</a></li></ul> <h2 id="BookInOnePage-CXFComponent">CXF Component</h2><div class="confluence-information-macro confluence-information-macro-note"><span class="aui-icon aui-icon-small aui-iconfont-warning confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>When using CXF as a consumer, the <a shape="rect" href="cxf-bean-component.html">CXF Bean Component</a> allows you to factor out how message payloads are received from their processing as a RESTful or SOAP web service. This has the potential of using a multitude of transports to consume web services. The bean component's configuration is also simpler and provides the fastest method to implement web services using Camel and CXF.</p></div></div><div class="confluence-information-macro confluence-information-macro-tip"><span class="aui-icon aui-icon-small aui-iconfont-approve confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>When using CXF in streaming modes (see DataFormat option), then also read about <a shape="rect" href="stream-caching.html">Stream caching</a>.</p></div></div><p>The <strong>cxf:</strong> component provides integration with <a shape="rect" href="http://cxf.apache.org">Apache CXF</a> for connecting to JAX-WS services hosted in CXF.</p><p><style type="text/css">/*<![CDATA[*/ -div.rbtoc1443511170768 {padding: 0px;} -div.rbtoc1443511170768 ul {list-style: disc;margin-left: 0px;} -div.rbtoc1443511170768 li {margin-left: 0px;padding-left: 0px;} +div.rbtoc1443687544352 {padding: 0px;} +div.rbtoc1443687544352 ul {list-style: disc;margin-left: 0px;} +div.rbtoc1443687544352 li {margin-left: 0px;padding-left: 0px;} -/*]]>*/</style></p><div class="toc-macro rbtoc1443511170768"> +/*]]>*/</style></p><div class="toc-macro rbtoc1443687544352"> <ul class="toc-indentation"><li><a shape="rect" href="#BookInOnePage-CXFComponent">CXF Component</a> <ul class="toc-indentation"><li><a shape="rect" href="#BookInOnePage-URIformat">URI format</a></li><li><a shape="rect" href="#BookInOnePage-Options">Options</a> <ul class="toc-indentation"><li><a shape="rect" href="#BookInOnePage-Thedescriptionsofthedataformats">The descriptions of the dataformats</a> Modified: websites/production/camel/content/book-pattern-appendix.html ============================================================================== --- websites/production/camel/content/book-pattern-appendix.html (original) +++ websites/production/camel/content/book-pattern-appendix.html Thu Oct 1 08:21:05 2015 @@ -2071,85 +2071,32 @@ from("direct:start") } ]]></script> </div></div><p>Notice that the return type is a List which we want to contain the user names. The 1st parameter is the list of names, and then notice the 2nd parameter is the incoming <code>com.foo.User</code> type.</p><h3 id="BookPatternAppendix-Seealso">See also</h3><ul class="alternate"><li>The <a shape="rect" href="loan-broker-example.html">Loan Broker Example</a> which uses an aggregator</li><li><a shape="rect" class="external-link" href="http://tmielke.blogspot.com/2009/01/using-camel-aggregator-correctly.html" rel="nofollow">Blog post by Torsten Mielke</a> about using the aggregator correctly.</li><li>The old <a shape="rect" href="aggregator.html">Aggregator</a></li><li><a shape="rect" href="hawtdb.html">HawtDB</a>, <a shape="rect" href="leveldb.html">LevelDB</a> or <a shape="rect" href="sql-component.html">SQL Component</a> for persistence support</li><li><a shape="rect" href="aggregate-example.html">Aggregate Example</a> for an example application</li></ul> -<h3 id="BookPatternAppendix-Resequencer">Resequencer</h3> - -<p>The <a shape="rect" class="external-link" href="http://www.enterpriseintegrationpatterns.com/Resequencer.html" rel="nofollow">Resequencer</a> from the <a shape="rect" href="enterprise-integration-patterns.html">EIP patterns</a> allows you to reorganise messages based on some comparator. By default in Camel we use an <a shape="rect" href="expression.html">Expression</a> to create the comparator; so that you can compare by a message header or the body or a piece of a message etc.</p> - -<p><span class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image confluence-external-resource" src="http://www.enterpriseintegrationpatterns.com/img/Resequencer.gif" data-image-src="http://www.enterpriseintegrationpatterns.com/img/Resequencer.gif"></span></p> - -<div class="confluence-information-macro confluence-information-macro-tip"><p class="title">Change in Camel 2.7</p><span class="aui-icon aui-icon-small aui-iconfont-approve confluence-information-macro-icon"></span><div class="confluence-information-macro-body"> -<p>The <code><batch-config></code> and <code><stream-config></code> tags in XML DSL in the Resequencer EIP must now be configured in the top, and not in the bottom. So if you use those, then move them up just below the <code><resequence></code> EIP starts in the XML. If you are using Camel older than 2.7, then those configs should be at the bottom.</p></div></div> - -<p>Camel supports two resequencing algorithms:</p> - -<ul><li><strong>Batch resequencing</strong> collects messages into a batch, sorts the messages and sends them to their output.</li><li><strong>Stream resequencing</strong> re-orders (continuous) message streams based on the detection of gaps between messages.</li></ul> - - -<p>By default the <a shape="rect" href="resequencer.html">Resequencer</a> does not support duplicate messages and will only keep the last message, in case a message arrives with the same message expression. However in the batch mode you can enable it to allow duplicates.</p> - -<h3 id="BookPatternAppendix-BatchResequencing">Batch Resequencing</h3> - -<p>The following example shows how to use the batch-processing resequencer so that messages are sorted in order of the <strong>body()</strong> expression. That is messages are collected into a batch (either by a maximum number of messages per batch or using a timeout) then they are sorted in order and then sent out to their output.</p> - -<p><strong>Using the <a shape="rect" href="fluent-builders.html">Fluent Builders</a></strong></p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<h3 id="BookPatternAppendix-Resequencer">Resequencer</h3><p>The <a shape="rect" class="external-link" href="http://www.enterpriseintegrationpatterns.com/Resequencer.html" rel="nofollow">Resequencer</a> from the <a shape="rect" href="enterprise-integration-patterns.html">EIP patterns</a> allows you to reorganise messages based on some comparator. By default in Camel we use an <a shape="rect" href="expression.html">Expression</a> to create the comparator; so that you can compare by a message header or the body or a piece of a message etc.</p><p><span class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image confluence-external-resource" src="http://www.enterpriseintegrationpatterns.com/img/Resequencer.gif" data-image-src="http://www.enterpriseintegrationpatterns.com/img/Resequencer.gif"></span></p><div class="confluence-information-macro confluence-information-macro-tip"><p class="title">Change in Camel 2.7</p><span class="aui-icon aui-icon-small aui-iconfont-appr ove confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>The <code><batch-config></code> and <code><stream-config></code> tags in XML DSL in the Resequencer EIP must now be configured in the top, and not in the bottom. So if you use those, then move them up just below the <code><resequence></code> EIP starts in the XML. If you are using Camel older than 2.7, then those configs should be at the bottom.</p></div></div><p>Camel supports two resequencing algorithms:</p><ul><li><strong>Batch resequencing</strong> collects messages into a batch, sorts the messages and sends them to their output.</li><li><strong>Stream resequencing</strong> re-orders (continuous) message streams based on the detection of gaps between messages.</li></ul><p>By default the <a shape="rect" href="resequencer.html">Resequencer</a> does not support duplicate messages and will only keep the last message, in case a message arrives with the same message expres sion. However in the batch mode you can enable it to allow duplicates.</p><h3 id="BookPatternAppendix-BatchResequencing">Batch Resequencing</h3><p>The following example shows how to use the batch-processing resequencer so that messages are sorted in order of the <strong>body()</strong> expression. That is messages are collected into a batch (either by a maximum number of messages per batch or using a timeout) then they are sorted in order and then sent out to their output.</p><p><strong>Using the <a shape="rect" href="fluent-builders.html">Fluent Builders</a></strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ from("direct:start") .resequence().body() .to("mock:result"); ]]></script> -</div></div> - -<p>This is equvalent to </p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ -from("direct:start") +</div></div>This is equivalent to<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from("direct:start") .resequence(body()).batch() .to("mock:result"); ]]></script> -</div></div> - -<p>The batch-processing resequencer can be further configured via the <code>size()</code> and <code>timeout()</code> methods.</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ -from("direct:start") +</div></div><p>The batch-processing resequencer can be further configured via the <code>size()</code> and <code>timeout()</code> methods.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from("direct:start") .resequence(body()).batch().size(300).timeout(4000L) .to("mock:result") ]]></script> -</div></div> - -<p>This sets the batch size to 300 and the batch timeout to 4000 ms (by default, the batch size is 100 and the timeout is 1000 ms). Alternatively, you can provide a configuration object.</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ -from("direct:start") +</div></div><p>This sets the batch size to 300 and the batch timeout to 4000 ms (by default, the batch size is 100 and the timeout is 1000 ms). Alternatively, you can provide a configuration object.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from("direct:start") .resequence(body()).batch(new BatchResequencerConfig(300, 4000L)) .to("mock:result") ]]></script> -</div></div> - - -<p>So the above example will reorder messages from endpoint <strong>direct:a</strong> in order of their bodies, to the endpoint <strong>mock:result</strong>. <br clear="none"> -Typically you'd use a header rather than the body to order things; or maybe a part of the body. So you could replace this expression with</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ -resequencer(header("mySeqNo")) +</div></div><p>So the above example will reorder messages from endpoint <strong>direct:a</strong> in order of their bodies, to the endpoint <strong>mock:result</strong>. <br clear="none"> Typically you'd use a header rather than the body to order things; or maybe a part of the body. So you could replace this expression with</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[resequencer(header("mySeqNo")) ]]></script> -</div></div> - -<p>for example to reorder messages using a custom sequence number in the header <code>mySeqNo</code>.</p> - -<p>You can of course use many different <a shape="rect" href="expression.html">Expression</a> languages such as <a shape="rect" href="xpath.html">XPath</a>, <a shape="rect" href="xquery.html">XQuery</a>, <a shape="rect" href="sql.html">SQL</a> or various <a shape="rect" href="scripting-languages.html">Scripting Languages</a>.</p> - -<p><strong>Using the <a shape="rect" href="spring-xml-extensions.html">Spring XML Extensions</a></strong></p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ -<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> +</div></div><p>for example to reorder messages using a custom sequence number in the header <code>mySeqNo</code>.</p><p>You can of course use many different <a shape="rect" href="expression.html">Expression</a> languages such as <a shape="rect" href="xpath.html">XPath</a>, <a shape="rect" href="xquery.html">XQuery</a>, <a shape="rect" href="sql.html">SQL</a> or various <a shape="rect" href="scripting-languages.html">Scripting Languages</a>.</p><p><strong>Using the <a shape="rect" href="spring-xml-extensions.html">Spring XML Extensions</a></strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="direct:start" /> <resequence> @@ -2163,26 +2110,7 @@ resequencer(header("mySeqNo")) </route> </camelContext> ]]></script> -</div></div> - -<h4 id="BookPatternAppendix-AllowDuplicates">Allow Duplicates</h4> -<p><strong>Available as of Camel 2.4</strong></p> - -<p>In the <code>batch</code> mode, you can now allow duplicates. In Java DSL there is a <code>allowDuplicates()</code> method and in Spring XML there is an <code>allowDuplicates=true</code> attribute on the <code><batch-config/></code> you can use to enable it.</p> - -<h4 id="BookPatternAppendix-Reverse">Reverse</h4> -<p><strong>Available as of Camel 2.4</strong></p> - -<p>In the <code>batch</code> mode, you can now reverse the expression ordering. By default the order is based on 0..9,A..Z, which would let messages with low numbers be ordered first, and thus also also outgoing first. In some cases you want to reverse order, which is now possible.</p> - -<p>In Java DSL there is a <code>reverse()</code> method and in Spring XML there is an <code>reverse=true</code> attribute on the <code><batch-config/></code> you can use to enable it.</p> - -<h4 id="BookPatternAppendix-ResequenceJMSmessagesbasedonJMSPriority">Resequence JMS messages based on JMSPriority</h4> -<p><strong>Available as of Camel 2.4</strong></p> - -<p>It's now much easier to use the <a shape="rect" href="resequencer.html">Resequencer</a> to resequence messages from <a shape="rect" href="jms.html">JMS</a> queues based on <code>JMSPriority</code>. For that to work you need to use the two new options <code>allowDuplicates</code> and <code>reverse</code>. </p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><h4 id="BookPatternAppendix-AllowDuplicates">Allow Duplicates</h4><p><strong>Available as of Camel 2.4</strong></p><p>In the <code>batch</code> mode, you can now allow duplicates. In Java DSL there is a <code>allowDuplicates()</code> method and in Spring XML there is an <code>allowDuplicates=true</code> attribute on the <code><batch-config/></code> you can use to enable it.</p><h4 id="BookPatternAppendix-Reverse">Reverse</h4><p><strong>Available as of Camel 2.4</strong></p><p>In the <code>batch</code> mode, you can now reverse the expression ordering. By default the order is based on 0..9,A..Z, which would let messages with low numbers be ordered first, and thus also also outgoing first. In some cases you want to reverse order, which is now possible.</p><p>In Java DSL there is a <code>reverse()</code> method and in Spring XML there is an <code>reverse=true</code> attribute on the <code><batch-config/></code> you can use to enable it.</p><h4 id="BookPatternApp endix-ResequenceJMSmessagesbasedonJMSPriority">Resequence JMS messages based on JMSPriority</h4><p><strong>Available as of Camel 2.4</strong></p><p>It's now much easier to use the <a shape="rect" href="resequencer.html">Resequencer</a> to resequence messages from <a shape="rect" href="jms.html">JMS</a> queues based on <code>JMSPriority</code>. For that to work you need to use the two new options <code>allowDuplicates</code> and <code>reverse</code>.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ from("jms:queue:foo") // sort by JMSPriority by allowing duplicates (message can have same JMSPriority) @@ -2191,16 +2119,7 @@ from("jms:queue:foo") .resequence(header("JMSPriority")).batch().timeout(3000).allowDuplicates().reverse() .to("mock:result"); ]]></script> -</div></div> - -<p>Notice this is <strong>only</strong> possible in the <code>batch</code> mode of the <a shape="rect" href="resequencer.html">Resequencer</a>.</p> - -<h4 id="BookPatternAppendix-Ignoreinvalidexchanges">Ignore invalid exchanges</h4> -<p><strong>Available as of Camel 2.9</strong></p> - -<p>The <a shape="rect" href="resequencer.html">resequencer</a> EIP will from Camel 2.9 onwards throw a <code>CamelExchangeException</code> if the incoming <a shape="rect" href="exchange.html">Exchange</a> is not valid for the resequencer - ie. the expression cannot be evaluated, such as a missing header. You can use the option <code>ignoreInvalidExchanges</code> to ignore these exceptions which means the <a shape="rect" href="resequencer.html">Resequencer</a> will then skip the invalid <a shape="rect" href="exchange.html">Exchange</a>.</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div>Notice this is <strong>only</strong> possible in the <code>batch</code> mode of the <a shape="rect" href="resequencer.html">Resequencer</a>.<h4 id="BookPatternAppendix-Ignoreinvalidexchanges">Ignore invalid exchanges</h4><p><strong>Available as of Camel 2.9</strong></p><p>The <a shape="rect" href="resequencer.html">Resequencer</a> EIP will from Camel 2.9 onwards throw a <code>CamelExchangeException</code> if the incoming <a shape="rect" href="exchange.html">Exchange</a> is not valid for the resequencer - ie. the expression cannot be evaluated, such as a missing header. You can use the option <code>ignoreInvalidExchanges</code> to ignore these exceptions which means the <a shape="rect" href="resequencer.html">Resequencer</a> will then skip the invalid <a shape="rect" href="exchange.html">Exchange</a>.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ from("direct:start") .resequence(header("seqno")).batch().timeout(1000) @@ -2208,65 +2127,27 @@ from("direct:start") .ignoreInvalidExchanges() .to("mock:result"); ]]></script> -</div></div> - -<p>This option is available for both batch and stream resequencer.</p> - -<h4 id="BookPatternAppendix-RejectOldExchanges">Reject Old Exchanges</h4> -<p><strong>Available as of Camel 2.11</strong></p> - -<p>This option can be used to prevent out of order messages from being sent regardless of the event that delivered messages downstream (capacity, timeout, etc). If enabled using <code>rejectOld()</code>, the <a shape="rect" href="resequencer.html">Resequencer</a> will throw a <code>MessageRejectedException</code> when an incoming <a shape="rect" href="exchange.html">Exchange</a> is "older" (based on the Comparator) than the last delivered message. This provides an extra level of control with regards to delayed message ordering. </p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ -from("direct:start") +</div></div>This option is available for both batch and stream resequencer.<h4 id="BookPatternAppendix-RejectOldExchanges">Reject Old Exchanges</h4><p><strong>Available as of Camel 2.11</strong></p><p>This option can be used to prevent out of order messages from being sent regardless of the event that delivered messages downstream (capacity, timeout, etc). If enabled using <code>rejectOld()</code>, the <a shape="rect" href="resequencer.html">Resequencer</a> will throw a <code>MessageRejectedException</code> when an incoming <a shape="rect" href="exchange.html">Exchange</a> is "older" (based on the Comparator) than the last delivered message. This provides an extra level of control with regards to delayed message ordering.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from("direct:start") .onException(MessageRejectedException.class).handled(true).to("mock:error").end() .resequence(header("seqno")).stream().timeout(1000).rejectOld() .to("mock:result"); ]]></script> -</div></div> - -<p>This option is available for the stream resequencer only.</p> - -<h3 id="BookPatternAppendix-StreamResequencing">Stream Resequencing</h3> - -<p>The next example shows how to use the stream-processing resequencer. Messages are re-ordered based on their sequence numbers given by a <code>seqnum</code> header using gap detection and timeouts on the level of individual messages. </p> - -<p><strong>Using the <a shape="rect" href="fluent-builders.html">Fluent Builders</a></strong></p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><p>This option is available for the stream resequencer only.</p><h3 id="BookPatternAppendix-StreamResequencing">Stream Resequencing</h3><p>The next example shows how to use the stream-processing resequencer. Messages are re-ordered based on their sequence numbers given by a <code>seqnum</code> header using gap detection and timeouts on the level of individual messages.</p><p><strong>Using the <a shape="rect" href="fluent-builders.html">Fluent Builders</a></strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ from("direct:start").resequence(header("seqnum")).stream().to("mock:result"); ]]></script> -</div></div> - -<p>The stream-processing resequencer can be further configured via the <code>capacity()</code> and <code>timeout()</code> methods.</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ -from("direct:start") +</div></div>The stream-processing resequencer can be further configured via the <code>capacity()</code> and <code>timeout()</code> methods.<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from("direct:start") .resequence(header("seqnum")).stream().capacity(5000).timeout(4000L) .to("mock:result") ]]></script> -</div></div> - -<p>This sets the resequencer's capacity to 5000 and the timeout to 4000 ms (by default, the capacity is 1000 and the timeout is 1000 ms). Alternatively, you can provide a configuration object.</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ -from("direct:start") +</div></div><p>This sets the resequencer's capacity to 5000 and the timeout to 4000 ms (by default, the capacity is 1000 and the timeout is 1000 ms). Alternatively, you can provide a configuration object.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from("direct:start") .resequence(header("seqnum")).stream(new StreamResequencerConfig(5000, 4000L)) .to("mock:result") ]]></script> -</div></div> - -<p>The stream-processing resequencer algorithm is based on the detection of gaps in a message stream rather than on a fixed batch size. Gap detection in combination with timeouts removes the constraint of having to know the number of messages of a sequence (i.e. the batch size) in advance. Messages must contain a unique sequence number for which a predecessor and a successor is known. For example a message with the sequence number 3 has a predecessor message with the sequence number 2 and a successor message with the sequence number 4. The message sequence 2,3,5 has a gap because the sucessor of 3 is missing. The resequencer therefore has to retain message 5 until message 4 arrives (or a timeout occurs). </p> - -<p>If the maximum time difference between messages (with successor/predecessor relationship with respect to the sequence number) in a message stream is known, then the resequencer's timeout parameter should be set to this value. In this case it is guaranteed that all messages of a stream are delivered in correct order to the next processor. The lower the timeout value is compared to the out-of-sequence time difference the higher is the probability for out-of-sequence messages delivered by this resequencer. Large timeout values should be supported by sufficiently high capacity values. The capacity parameter is used to prevent the resequencer from running out of memory. </p> - -<p>By default, the stream resequencer expects <code>long</code> sequence numbers but other sequence numbers types can be supported as well by providing a custom expression.</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><p>The stream-processing resequencer algorithm is based on the detection of gaps in a message stream rather than on a fixed batch size. Gap detection in combination with timeouts removes the constraint of having to know the number of messages of a sequence (i.e. the batch size) in advance. Messages must contain a unique sequence number for which a predecessor and a successor is known. For example a message with the sequence number 3 has a predecessor message with the sequence number 2 and a successor message with the sequence number 4. The message sequence 2,3,5 has a gap because the successor of 3 is missing. The resequencer therefore has to retain message 5 until message 4 arrives (or a timeout occurs).</p><p>If the maximum time difference between messages (with successor/predecessor relationship with respect to the sequence number) in a message stream is known, then the resequencer's timeout parameter should be set to this value. In this case it is guaranteed that all messages of a stream are delivered in correct order to the next processor. The lower the timeout value is compared to the out-of-sequence time difference the higher is the probability for out-of-sequence messages delivered by this resequencer. Large timeout values should be supported by sufficiently high capacity values. The capacity parameter is used to prevent the resequencer from running out of memory.</p><p>By default, the stream resequencer expects <code>long</code> sequence numbers but other sequence numbers types can be supported as well by providing a custom expression.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ public class MyFileNameExpression implements Expression { @@ -2290,44 +2171,26 @@ public class MyFileNameExpression implem } ]]></script> -</div></div> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ from("direct:start").resequence(new MyFileNameExpression()).stream().timeout(100).to("mock:result"); ]]></script> -</div></div> - -<p>or custom comparator via the <code>comparator()</code> method</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ -ExpressionResultComparator<Exchange> comparator = new MyComparator(); +</div></div>or custom comparator via the <code>comparator()</code> method<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ExpressionResultComparator<Exchange> comparator = new MyComparator(); from("direct:start") .resequence(header("seqnum")).stream().comparator(comparator) .to("mock:result"); ]]></script> -</div></div> - -<p>or via a <code>StreamResequencerConfig</code> object.</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ -ExpressionResultComparator<Exchange> comparator = new MyComparator(); +</div></div><p>or via a <code>StreamResequencerConfig</code> object.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ExpressionResultComparator<Exchange> comparator = new MyComparator(); StreamResequencerConfig config = new StreamResequencerConfig(100, 1000L, comparator); from("direct:start") .resequence(header("seqnum")).stream(config) .to("mock:result"); ]]></script> -</div></div> - - -<p><strong>Using the <a shape="rect" href="spring-xml-extensions.html">Spring XML Extensions</a></strong></p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ -<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> +</div></div><p><strong>Using the <a shape="rect" href="spring-xml-extensions.html">Spring XML Extensions</a></strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="direct:start"/> <resequence> @@ -2338,13 +2201,7 @@ from("direct:start") </route> </camelContext> ]]></script> -</div></div> - -<h3 id="BookPatternAppendix-FurtherExamples">Further Examples</h3> - -<p>For further examples of this pattern in use you could look at the <a shape="rect" class="external-link" href="http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ResequencerTest.java?view=markup">batch-processing resequencer junit test case</a> and the <a shape="rect" class="external-link" href="http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/StreamResequencerTest.java?view=markup">stream-processing resequencer junit test case</a></p> - -<h4 id="BookPatternAppendix-UsingThisPattern.20">Using This Pattern</h4> +</div></div><h3 id="BookPatternAppendix-FurtherExamples">Further Examples</h3><p>For further examples of this pattern in use you could look at the <a shape="rect" class="external-link" href="http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ResequencerTest.java?view=markup">batch-processing resequencer junit test case</a> and the <a shape="rect" class="external-link" href="http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/StreamResequencerTest.java?view=markup">stream-processing resequencer junit test case</a></p><p></p><h4 id="BookPatternAppendix-UsingThisPattern.20">Using This Pattern</h4> <p>If you would like to use this EIP Pattern then please read the <a shape="rect" href="getting-started.html">Getting Started</a>, you may also find the <a shape="rect" href="architecture.html">Architecture</a> useful particularly the description of <a shape="rect" href="endpoint.html">Endpoint</a> and <a shape="rect" href="uris.html">URIs</a>. Then you could try out some of the <a shape="rect" href="examples.html">Examples</a> first before trying this pattern out.</p> <h3 id="BookPatternAppendix-ComposedMessageProcessor">Composed Message Processor</h3> Modified: websites/production/camel/content/cache/main.pageCache ============================================================================== Binary files - no diff available.