Author: buildbot
Date: Wed Nov  2 18:18:56 2016
New Revision: 1000387

Log:
Production update by buildbot for camel

Modified:
    websites/production/camel/content/cache/main.pageCache
    websites/production/camel/content/notifybuilder.html

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

Modified: websites/production/camel/content/notifybuilder.html
==============================================================================
--- websites/production/camel/content/notifybuilder.html (original)
+++ websites/production/camel/content/notifybuilder.html Wed Nov  2 18:18:56 
2016
@@ -84,185 +84,92 @@
        <tbody>
         <tr>
         <td valign="top" width="100%">
-<div class="wiki-content maincontent"><h2 
id="NotifyBuilder-NotifyBuilder">NotifyBuilder</h2>
-<p><strong>Available as of Camel 2.2</strong></p>
-
-<p>The <code>NotifyBuilder</code> is a builder from the 
<code>org.apache.camel.builder</code> package which allows you to build 
expressions and then test or wait for that condition to occur. The expressions 
is based around notifications about <a shape="rect" 
href="exchange.html">Exchange</a> being routed. So what does that mean? It 
means that you can build an expressions which can tell you when Camel is 
finished with routing 5 messages etc.</p>
-
-<p>You may want to use this when testing a route which you cannot or will not 
use <a shape="rect" href="mock.html">Mock</a>s. </p>
-
-<p>Suppose we have a very simple route:</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(&quot;jms:queue:quotes&quot;)
-     .to(&quot;bean:quotes&quot;);
-]]></script>
-</div></div>
-
-<p>Now you want to test this route without using mocks or the likes. Imagine 
the route being more complex and a production ready route.<br clear="none">
-We want to test that it could process a message send to that queue. By using 
the <a shape="rect" href="notifybuilder.html">NotifyBuilder</a> we can build an 
expression which <em>expresses when that condition occurred</em>.</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[ 
-  NotifyBuilder notify = new NotifyBuilder().whenDone(1).create();
-
-  // now use some API to send a message etc. Maybe you cannot use Camel&#39;s 
ProducerTemplate
-  // now we want to wait until the message has been routed and completed
-
-  boolean done = notify.matches(10, TimeUnit.SECONDS);
-  assertTrue(&quot;Should be done&quot;, done);
-
-  // now maybe use some API to see that the message did as expected
-]]></script>
-</div></div>
-
-<p>This is a very basic example with a simple builder expression. What we said 
that we want it to match when any Exchange is done. The builder have many more 
methods to set more complex expressions, which even can be stacked using 
<strong>and, or, not</strong> operations.</p>
-
-<h3 id="NotifyBuilder-Methods">Methods</h3>
-
-<p>These methods is for building the expression:</p>
-
-<div class="table-wrap"><table class="confluenceTable"><tbody><tr><th 
colspan="1" rowspan="1" class="confluenceTh"><p> Method </p></th><th 
colspan="1" rowspan="1" class="confluenceTh"><p> Description 
</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> 
from(endpointUri) </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> 
Matches only when <a shape="rect" href="exchange.html">Exchange</a>s are 
incoming from that particular endpoint. The endpointUri can be a pattern, which 
is the same pattern matching used by <a shape="rect" 
href="intercept.html">Intercept</a>. </p></td></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd"><p> fromRoute(routeId) </p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p> <strong>Camel 2.4:</strong> 
Matches only when <a shape="rect" href="exchange.html">Exchange</a>s are 
incoming from that particular route. The routeId can be a pattern, which is the 
same pattern matching used by <a shape="rect" href="intercept.html">In
 tercept</a>. </p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p> filter(predicate) </p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p> Filters out unwanted <a shape="rect" 
href="exchange.html">Exchange</a>s (only messages passing (true) the predicate 
is used). </p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p> wereSentTo(endpointUri) </p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p> <strong>Camel 2.9:</strong> Matches only 
when <a shape="rect" href="exchange.html">Exchange</a>s has at any point been 
sent to the given endpoint. The endpointUri can be a pattern, which is the same 
pattern matching used by <a shape="rect" href="intercept.html">Intercept</a>. 
</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> 
whenReceived(number) </p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p> Matches when X number or more messages has been 
received. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluen
 ceTd"><p> whenDone(number) </p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p> Matches when X number or more messages is done. 
</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> 
whenDoneByIndex(index) </p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p> <strong>Camel 2.8:</strong> Matches when the n'th 
(index) message is done. </p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p> whenComplete(number) </p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p> Matches when X number or more messages is 
complete. </p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p> whenFailed(number) </p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p> Matches when X number or more messages is 
failed. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> 
whenExactlyDone(number) </p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p> Matches when exactly X number of messages is done. 
</p></td></tr
 ><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> 
 >whenExactlyComplete(number) </p></td><td colspan="1" rowspan="1" 
 >class="confluenceTd"><p> Matches when exactly X number of messages is 
 >complete. </p></td></tr><tr><td colspan="1" rowspan="1" 
 >class="confluenceTd"><p> whenExactlyFailed(number) </p></td><td colspan="1" 
 >rowspan="1" class="confluenceTd"><p> Matches when exactly X number of 
 >messages is failed. </p></td></tr><tr><td colspan="1" rowspan="1" 
 >class="confluenceTd"><p> whenBodiesReceived(bodies) </p></td><td colspan="1" 
 >rowspan="1" class="confluenceTd"><p> Matches when the message bodies has been 
 >received in the same order. This method is non strict which means that it 
 >will disregard any additional received messages. </p></td></tr><tr><td 
 >colspan="1" rowspan="1" class="confluenceTd"><p> 
 >whenExactBodiesReceived(bodies) </p></td><td colspan="1" rowspan="1" 
 >class="confluenceTd"><p> Matches when the message bodies has been received in 
 >the same order. This method is strict wh
 ich means the exact number of message bodies is expected. 
</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> 
whenBodiesDone(bodies) </p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p> Matches when the message bodies are done in the same 
order. This method is non strict which means that it will disregard any 
additional done messages. </p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p> whenExactBodiesDone(bodies) </p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p> Matches when the message bodies are done 
in the same order. This method is strict which means the exact number of 
message bodies is expected. </p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p> whenAnyReceivedMatches(predicate) </p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p> Matches if any one of the 
received messages matched the <a shape="rect" 
href="predicate.html">Predicate</a>. </p></td></tr><tr><td colspan="1" 
rowspan="1" class="
 confluenceTd"><p> whenAllReceivedMatches(predicate) </p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p> Matches only when all of the received 
messages matched the <a shape="rect" href="predicate.html">Predicate</a>. 
</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> 
whenAnyDoneMatches(predicate) </p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p> Matches if any one of the done messages matched the <a 
shape="rect" href="predicate.html">Predicate</a>. </p></td></tr><tr><td 
colspan="1" rowspan="1" class="confluenceTd"><p> whenAllDoneMatches(predicate) 
</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Matches only when 
all of the done messages matched the <a shape="rect" 
href="predicate.html">Predicate</a>. </p></td></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd"><p> whenReceivedSatisfied(mock) </p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p> Matches if the <a shape="rect" 
href="mock.html">Mock</a> is satisfied f
 or received messages. Is used for fine grained matching by setting the 
expectations on the <a shape="rect" href="mock.html">Mock</a> which already 
have a great library for doing so. </p></td></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd"><p> whenReceivedNotSatisfied(mock) 
</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Matches if the <a 
shape="rect" href="mock.html">Mock</a> is <strong>not</strong> satisfied for 
received messages. Is used for fine grained matching by setting the 
expectations on the <a shape="rect" href="mock.html">Mock</a> which already 
have a great library for doing so. </p></td></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd"><p> whenDoneSatisfied(mock) </p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p> Matches if the <a shape="rect" 
href="mock.html">Mock</a> is satisfied for messages done. Is used for fine 
grained matching by setting the expectations on the <a shape="rect" 
href="mock.html">Mock</a> which already have a
  great library for doing so. </p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p> whenDoneNotSatisfied(mock) </p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p> Matches if the <a shape="rect" 
href="mock.html">Mock</a> is <strong>not</strong> satisfied for messages done. 
Is used for fine grained matching by setting the expectations on the <a 
shape="rect" href="mock.html">Mock</a> which already have a great library for 
doing so. </p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p> and </p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p> Appends an additional expressions using the 
<strong>and</strong> operator. </p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p> or </p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p> Appends an additional expressions using the 
<strong>or</strong> operator. </p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p> not </p></td><td colspan="1" rowspan="1" clas
 s="confluenceTd"><p> Appends an additional expressions using the 
<strong>not</strong> operator. </p></td></tr></tbody></table></div>
-
-
-<p>And these methods is for using the builder after creating the 
expression:</p>
-<div class="table-wrap"><table class="confluenceTable"><tbody><tr><th 
colspan="1" rowspan="1" class="confluenceTh"><p> Method </p></th><th 
colspan="1" rowspan="1" class="confluenceTh"><p> Description 
</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> create() 
</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Creates the 
builder expression. After you have <strong>created</strong> it you can use the 
<code>matches</code> methods. </p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p> matches() </p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p> Does the builder match currently. This operation 
returns immediately. This method is to be used <strong>after</strong> you have 
created the expression. </p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p> matches(timeout, TimeUnit) </p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p> Wait until the builder matches or timeout. 
This method is to be used <strong>af
 ter</strong> you have created the expression. </p></td></tr><tr><td 
colspan="1" rowspan="1" class="confluenceTd"><p> matchesMockWaitTime 
</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> <strong>Camel 
2.6:</strong> Wait until the builder matches or timeout. The timeout value used 
is based on the <em>highest result wait time</em> configured on any of mock 
endpoints being used. If no mock endpoint was used, then the default timeout 
value is 10 seconds. This method is convenient to use in unit tests when you 
use mocks. Then you dont have to specify the timeout value explicit. 
</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> reset() 
</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> <strong>Camel 
2.3:</strong> Resets the notifier. </p></td></tr></tbody></table></div>
-
-
-<p>We will most likely add additional methods in the future, so check out the 
<code>NotifyBuilder</code> for latest and greatest methods.</p>
-
-<h3 id="NotifyBuilder-DifferencebetweenDoneandCompleted">Difference between 
Done and Completed</h3>
-<p>The difference between <strong>done</strong> and <strong>completed</strong> 
is that done can also include failed messages, where as completed is only 
successful processed messages.</p>
-
-<h3 id="NotifyBuilder-Examples">Examples</h3>
-<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[
-        NotifyBuilder notify = new NotifyBuilder(context)
-                .from(&quot;direct:foo&quot;).whenDone(5)
-                .create();
-]]></script>
-</div></div>
-<p>Here we want to match when the <code>direct:foo</code> endpoint have done 5 
messages. </p>
-
-<p>You may also want to be notified when an message is done by the index, for 
example the very first message. To do that you can simply do:</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[
-        NotifyBuilder notify = new NotifyBuilder(context)
-                .whenDoneByIndex(0)
-                .create();
-]]></script>
-</div></div>
-
-<p>This ensures that the notifier only matches exactly when the first message 
is done.</p>
-
-<p>If you use <code>whenDone(1)</code> instead, then the notifier matches when 
at least one message is done. There could be use cases where 
<code>whenDone(1)</code> would match even if the first message hasn't been done 
yet, as other message in between could be done ahead of the first message. That 
is why <code>whenDoneByIndex</code> was introduced in <strong>Camel 
2.8</strong> onwards to support this scenario.</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[
-        NotifyBuilder notify = new NotifyBuilder(context)
-                
.from(&quot;direct:foo&quot;).filter(body().contains(&quot;test&quot;)).whenDone(5)
-                .create();
-]]></script>
-</div></div>
-<p>Here we want to match when the <code>direct:foo</code> endpoint have done 5 
messages which contains the word 'test' in the body.<br clear="none">
-The filter accepts a <a shape="rect" href="predicate.html">Predicate</a> so 
you can use <a shape="rect" href="xpath.html">XPath</a>, <a shape="rect" 
href="bean.html">Bean</a>, <a shape="rect" href="simple.html">Simple</a> and 
whatnot. </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[
-        NotifyBuilder notify = new NotifyBuilder(context)
-                .from(&quot;jms:*&quot;).whenDone(1)
-                .create();
-]]></script>
-</div></div>
-<p>Here we just say that at least one message should be done received from any 
JMS endpoint (notice the wildcard matching).</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[
-        NotifyBuilder notify = new NotifyBuilder(context)
-                .fromRoute(&quot;myCoolRoutes*&quot;).whenDone(3)
-                .create();
-]]></script>
-</div></div>
-<p>Here we just say that at least three message should be done received from 
any of myCoolRoutes (notice the wildcard matching).</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[
-        NotifyBuilder notify = new NotifyBuilder(context)
-                .from(&quot;direct:foo&quot;).whenDone(5)
-                .and().from(&quot;direct:bar&quot;).whenDone(7)
-                .create();
-]]></script>
-</div></div>
-<p>Here both 5 foo messages and 7 bar messages must be done. Notice the use of 
the <strong>and</strong> operator.</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[
-        NotifyBuilder notify = new NotifyBuilder(context)
-                .from(&quot;direct:foo&quot;).whenBodiesReceived(&quot;Hello 
World&quot;, &quot;Bye World&quot;)
-                .create();
-]]></script>
-</div></div>
-<p>Here we expect to receive two messages with <code>Hello World</code> and 
<code>Bye World</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[
-        NotifyBuilder notify = new NotifyBuilder(context)
-                .whenAnyReceivedMatches(body().contains(&quot;Camel&quot;))
-                .create();
-]]></script>
-</div></div>
-<p>Here we want to match when we have received a message which contains Camel 
in the body.</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[
-        // lets use a mock to set the expressions as it got many great 
assertions for that
-        // notice we use mock:assert which does NOT exist in the route, its 
just a pseudo name
-        MockEndpoint mock = getMockEndpoint(&quot;mock:assert&quot;);
-        mock.expectedBodiesReceivedInAnyOrder(&quot;Hello World&quot;, 
&quot;Bye World&quot;, &quot;Hi World&quot;);
-
-        NotifyBuilder notify = new NotifyBuilder(context)
-                .from(&quot;direct:foo&quot;).whenReceivedSatisfied(mock)
-                .create();
-]]></script>
-</div></div>
-<p>Now it bring powers to the table. We combine a mock with the builder. We 
use the mock to set fine grained expectations such as we should receive 3 
messages in any order. Then using the builder we can tell that those messages 
should be received from the <code>direct:foo</code> endpoint.</p>
-
-<p>You can combine multiple expressions as much as you like. However we 
suggest to use the mock for fine grained expectations that you may already know 
how to use.</p>
-
-<p>You can also specify that the <a shape="rect" 
href="exchange.html">Exchange</a>s must have been sent to a given endpoint. For 
example in the following we expect the message to be sent to mock:bar</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[
-        NotifyBuilder notify = new NotifyBuilder(context)
-                .wereSentTo(&quot;mock:bar&quot;)
-                .create();
-]]></script>
-</div></div>
-
-<p>You can combine this with any of the other expectations, such as, to only 
match if 3+ messages are done, and were sent to the mock:bar endpoint:</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[
-        NotifyBuilder notify = new NotifyBuilder(context)
-                .whenDone(3).wereSentTo(&quot;mock:bar&quot;)
-                .create();
-]]></script>
-</div></div>
-
-<p>You can add additional {{wereSentTo}}s, such as the following two:</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[
-        NotifyBuilder notify = new NotifyBuilder(context)
-                
.wereSentTo(&quot;activemq:queue:foo&quot;).wereSentTo(&quot;activemq:queue:bar&quot;)
-                .create();
-]]></script>
-</div></div>
-
-<p>As well as you can expect a number of messages to be done, and a message to 
fail, which has to be sent to another endpoint:</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[
-        NotifyBuilder notify = new NotifyBuilder(context)
-                .whenDone(3).wereSentTo(&quot;activemq:queue:goodOrder&quot;)
-                
.and().whenFailed(1).wereSentTo(&quot;activemq:queue:badOrder&quot;)
-                .create();
+<div class="wiki-content maincontent"><h2 
id="NotifyBuilder-NotifyBuilder">NotifyBuilder</h2><p><strong>Available from 
Camel 2.2</strong></p><p>The <strong><code>NotifyBuilder</code></strong> is a 
builder from the <strong><code>org.apache.camel.builder</code></strong> package 
which allows you to build expressions and then test or wait for that condition 
to occur. The expressions is based around notifications about <a shape="rect" 
href="exchange.html">Exchange</a> being routed. So what does that mean? It 
means that you can build an expressions which can tell you when Camel is 
finished with routing 5 messages etc.</p><p>You may want to use this when 
testing a route which you cannot or will not use <a shape="rect" 
href="mock.html">Mock</a>s.</p><p>Suppose we have a very simple route:</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(&quot;jms:queue:quotes&quot;)
+    .to(&quot;bean:quotes&quot;);
+]]></script>
+</div></div><p>Now you want to test this route without using mocks or the 
likes. Imagine the route being more complex and a production ready route.<br 
clear="none"> We want to test that it could process a message send to that 
queue. By using the <a shape="rect" href="notifybuilder.html">NotifyBuilder</a> 
we can build an expression which <em>expresses when that condition 
occurred</em>.</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[NotifyBuilder notify = new 
NotifyBuilder().whenDone(1).create();
+
+// now use some API to send a message etc. Maybe you cannot use Camel&#39;s 
ProducerTemplate
+// now we want to wait until the message has been routed and completed
+
+boolean done = notify.matches(10, TimeUnit.SECONDS);
+assertTrue(&quot;Should be done&quot;, done);
+
+// now maybe use some API to see that the message did as expected
+]]></script>
+</div></div><p>This is a very basic example with a simple builder expression. 
What we said that we want it to match when any Exchange is done. The builder 
have many more methods to set more complex expressions, which even can be 
stacked using <strong><code>and</code>, 
<code>or</code></strong>,&#160;<strong><code>not</code></strong> 
operations.</p><h3 id="NotifyBuilder-Methods">Methods</h3><p>These methods is 
for building the expression:</p><div class="table-wrap"><table 
class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Method</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>from(endpointUri)</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>Matches only when <a 
shape="rect" href="exchange.html">Exchange</a>s are incoming from that 
particular endpoint. The&#160;<strong><code>endpointUri</code></strong> can be 
a pattern, which is the s
 ame pattern matching used by <a shape="rect" 
href="intercept.html">Intercept</a>.</p></td></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>fromRoute(routeId)</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.4:</strong> 
Matches only when <a shape="rect" href="exchange.html">Exchange</a>s are 
incoming from that particular route. 
The&#160;<strong><code>routeId</code></strong> can be a pattern, which is the 
same pattern matching used by <a shape="rect" 
href="intercept.html">Intercept</a>.</p></td></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>filter(predicate)</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>Filters out unwanted <a 
shape="rect" href="exchange.html">Exchange</a>s (only messages passing (true) 
the predicate is used).</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>wereSentTo(endpointUri)</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><st
 rong>Camel 2.9:</strong> Matches only when <a shape="rect" 
href="exchange.html">Exchange</a>s has at any point been sent to the given 
endpoint. The&#160;<strong><code>endpointUri</code></strong> can be a pattern, 
which is the same pattern matching used by <a shape="rect" 
href="intercept.html">Intercept</a>.</p></td></tr><tr><td colspan="1" 
rowspan="1" 
class="confluenceTd"><p><code>whenReceived(number)</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>Matches when X number or more 
messages has been received.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>whenDone(number)</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p>Matches when X number or more messages is 
done.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>whenDoneByIndex(index)</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.8:</strong> 
Matches when the N'th (index) message is done.</p></td></tr><tr><td
  colspan="1" rowspan="1" 
class="confluenceTd"><p><code>whenComplete(number)</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>Matches when X number or more 
messages is complete.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>whenFailed(number)</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p>Matches when X number or more messages is 
failed.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>whenExactlyDone(number)</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>Matches when exactly X number 
of messages is done.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>whenExactlyComplete(number)</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>Matches when exactly X number 
of messages is complete.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>whenExactlyFailed(number)</code></p></td><td 
colspan="1" rowspan="1" class
 ="confluenceTd"><p>Matches when exactly X number of messages is 
failed.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>whenBodiesReceived(bodies)</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>Matches when the message bodies 
has been received in the same order. This method is non strict which means that 
it will disregard any additional received messages.</p></td></tr><tr><td 
colspan="1" rowspan="1" 
class="confluenceTd"><p><code>whenExactBodiesReceived(bodies)</code></p></td><td
 colspan="1" rowspan="1" class="confluenceTd"><p>Matches when the message 
bodies has been received in the same order. This method is strict which means 
the exact number of message bodies is expected.</p></td></tr><tr><td 
colspan="1" rowspan="1" 
class="confluenceTd"><p><code>whenBodiesDone(bodies)</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>Matches when the message bodies 
are done in the same order. This method is non strict which means that
  it will disregard any additional done messages.</p></td></tr><tr><td 
colspan="1" rowspan="1" 
class="confluenceTd"><p><code>whenExactBodiesDone(bodies)</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>Matches when the message bodies 
are done in the same order. This method is strict which means the exact number 
of message bodies is expected.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>whenAnyReceivedMatches(predicate)</code></p></td><td
 colspan="1" rowspan="1" class="confluenceTd"><p>Matches if any one of the 
received messages matched the <a shape="rect" 
href="predicate.html">Predicate</a>.</p></td></tr><tr><td colspan="1" 
rowspan="1" 
class="confluenceTd"><p><code>whenAllReceivedMatches(predicate)</code></p></td><td
 colspan="1" rowspan="1" class="confluenceTd"><p>Matches only when all of the 
received messages matched the <a shape="rect" 
href="predicate.html">Predicate</a>.</p></td></tr><tr><td colspan="1" 
rowspan="1" class="confluenceT
 d"><p><code>whenAnyDoneMatches(predicate)</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p>Matches if any one of the done messages 
matched the <a shape="rect" 
href="predicate.html">Predicate</a>.</p></td></tr><tr><td colspan="1" 
rowspan="1" 
class="confluenceTd"><p><code>whenAllDoneMatches(predicate)</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>Matches only when all of the 
done messages matched the <a shape="rect" 
href="predicate.html">Predicate</a>.</p></td></tr><tr><td colspan="1" 
rowspan="1" 
class="confluenceTd"><p><code>whenReceivedSatisfied(mock)</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>Matches if the <a shape="rect" 
href="mock.html">Mock</a> is satisfied for received messages. Is used for fine 
grained matching by setting the expectations on the <a shape="rect" 
href="mock.html">Mock</a> which already have a great library for doing 
so.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>whenR
 eceivedNotSatisfied(mock)</code></p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>Matches if the <a shape="rect" 
href="mock.html">Mock</a> is <strong>not</strong> satisfied for received 
messages. Is used for fine grained matching by setting the expectations on the 
<a shape="rect" href="mock.html">Mock</a> which already have a great library 
for doing so.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>whenDoneSatisfied(mock)</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>Matches if the <a shape="rect" 
href="mock.html">Mock</a> is satisfied for messages done. Is used for fine 
grained matching by setting the expectations on the <a shape="rect" 
href="mock.html">Mock</a> which already have a great library for doing 
so.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>whenDoneNotSatisfied(mock)</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>Matches if the <a shape="rect" 
href="mock.html
 ">Mock</a> is <strong>not</strong> satisfied for messages done. Is used for 
fine grained matching by setting the expectations on the <a shape="rect" 
href="mock.html">Mock</a> which already have a great library for doing 
so.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>and</code></p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>Appends an additional expressions using 
the&#160;<strong><code>and</code></strong> operator.</p></td></tr><tr><td 
colspan="1" rowspan="1" class="confluenceTd"><p><code>or</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>Appends an additional 
expressions using the&#160;<strong><code>or</code></strong> 
operator.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>not</code></p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>Appends an additional expressions using 
the&#160;<strong><code>not</code></strong> 
operator.</p></td></tr></tbody></table></div><p>And these methods is
  for using the builder after creating the expression:</p><div 
class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" 
rowspan="1" class="confluenceTh"><p>Method</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>create()</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>Creates the builder expression. 
After you have <em><strong>created</strong></em> it you can use the 
<code>matches</code> methods.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>matches()</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p>Does the builder match currently. This 
operation returns immediately. This method is to be used 
<em><strong>after</strong></em> you have created the 
expression.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>matches(timeout, TimeUnit)</code></p></td><td 
colspan="1" rowspan="1" clas
 s="confluenceTd"><p>Wait until the builder matches or timeout. This method is 
to be used <em><strong>after</strong></em> you have created the 
expression.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>matchesMockWaitTime</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.6:</strong> 
Wait until the builder matches or timeout. The timeout value used is based on 
the <strong><em>highest result wait time</em></strong> configured on any of 
mock endpoints being used. If no mock endpoint was used, then the default 
timeout value is&#160;<strong><code>10</code></strong> seconds. This method is 
convenient to use in unit tests when you use mocks. Then you don't have to 
specify the timeout value explicit.</p></td></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>reset()</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.3:</strong> 
Resets the notifier.</p></td></tr></tbody></table></div><
 p>We will most likely add additional methods in the future, so check out the 
<strong><code>NotifyBuilder</code></strong> for latest and greatest 
methods.</p><h3 id="NotifyBuilder-DifferenceBetweenDoneandCompleted">Difference 
Between&#160;<code>Done</code> and&#160;<code>Completed</code></h3><p>The 
difference between&#160;<strong><code>done</code></strong> 
and&#160;<strong><code>completed</code></strong> is that done can also include 
failed messages, where as completed is only successful processed 
messages.</p><h3 id="NotifyBuilder-Examples">Examples</h3><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[NotifyBuilder notify = new 
NotifyBuilder(context)
+    .from(&quot;direct:foo&quot;).whenDone(5)
+    .create();
+]]></script>
+</div></div><p>Here we want to match when the 
<strong><code>direct:foo</code></strong> endpoint have done 5 
messages.</p><p>You may also want to be notified when an message is done by the 
index, for example the very first message. To do that you can simply 
do:</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[NotifyBuilder notify = new 
NotifyBuilder(context)
+    .whenDoneByIndex(0)
+    .create();
+]]></script>
+</div></div><p>This ensures that the notifier only matches exactly when the 
first message is done.</p><p>If you use 
<strong><code>whenDone(1)</code></strong> instead, then the notifier matches 
when at least one message is done. There could be use cases where 
<strong><code>whenDone(1)</code></strong> would match even if the first message 
hasn't been done yet, as other message in between could be done ahead of the 
first message. That is why <strong><code>whenDoneByIndex</code></strong> was 
introduced in <strong>Camel 2.8</strong> to support this scenario.</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[NotifyBuilder notify = new 
NotifyBuilder(context)
+    
.from(&quot;direct:foo&quot;).filter(body().contains(&quot;test&quot;)).whenDone(5)
+    .create();
+]]></script>
+</div></div><p>Here we want to match when the 
<strong><code>direct:foo</code></strong> endpoint have done 5 messages which 
contains the word '<strong><code>test</code></strong>' in the body.<br 
clear="none"> The filter accepts a <a shape="rect" 
href="predicate.html">Predicate</a> so you can use <a shape="rect" 
href="xpath.html">XPath</a>, <a shape="rect" href="bean.html">Bean</a>, <a 
shape="rect" href="simple.html">Simple</a> and whatnot.</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[NotifyBuilder notify = new 
NotifyBuilder(context)
+    .from(&quot;jms:*&quot;).whenDone(1)
+    .create();
+]]></script>
+</div></div><p>Here we just say that at least one message should be done 
received from any JMS endpoint (notice the wildcard matching).</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[NotifyBuilder notify = new 
NotifyBuilder(context)
+    .fromRoute(&quot;myCoolRoutes*&quot;).whenDone(3)
+    .create();
+]]></script>
+</div></div><p>Here, we just say that at least three message should be done 
received from any of&#160;<strong><code>myCoolRoutes</code></strong> (notice 
the wildcard matching).</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[NotifyBuilder notify = new 
NotifyBuilder(context)
+    .from(&quot;direct:foo&quot;).whenDone(5)
+    .and().from(&quot;direct:bar&quot;).whenDone(7)
+    .create();
+]]></script>
+</div></div><p>Here both&#160;<strong><code>5</code></strong> foo messages 
and&#160;<strong><code>7</code></strong> bar messages must be done. Notice the 
use of the <strong><code>and</code></strong> operator.</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[NotifyBuilder notify = new 
NotifyBuilder(context)
+    .from(&quot;direct:foo&quot;).whenBodiesReceived(&quot;Hello World&quot;, 
&quot;Bye World&quot;)
+    .create();
+]]></script>
+</div></div><p>Here we expect to receive two messages with <strong><code>Hello 
World</code></strong> and <strong><code>Bye World</code></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[NotifyBuilder notify = new 
NotifyBuilder(context)
+    .whenAnyReceivedMatches(body().contains(&quot;Camel&quot;))
+    .create();
+]]></script>
+</div></div><p>Here we want to match when we have received a message which 
contains Camel in the body.</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[// lets use a mock to set the expressions as 
it got many great assertions for that
+// notice we use mock:assert which does NOT exist in the route, its just a 
pseudo name
+MockEndpoint mock = getMockEndpoint(&quot;mock:assert&quot;);
+mock.expectedBodiesReceivedInAnyOrder(&quot;Hello World&quot;, &quot;Bye 
World&quot;, &quot;Hi World&quot;);
+
+NotifyBuilder notify = new NotifyBuilder(context)
+    .from(&quot;direct:foo&quot;).whenReceivedSatisfied(mock)
+    .create();
+]]></script>
+</div></div><p>Now it bring powers to the table. We combine a mock with the 
builder. We use the mock to set fine grained expectations such as we should 
receive 3 messages in any order. Then using the builder we can tell that those 
messages should be received from the <strong><code>direct:foo</code></strong> 
endpoint. You can combine multiple expressions as much as you like. However we 
suggest to use the mock for fine grained expectations that you may already know 
how to use. You can also specify that the <a shape="rect" 
href="exchange.html">Exchange</a>s must have been sent to a given 
endpoint.</p><p>For example in the following we expect the message to be sent 
to&#160;<strong><code>mock:bar</code></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[NotifyBuilder notify = new 
NotifyBuilder(context)
+    .wereSentTo(&quot;mock:bar&quot;)
+    .create();
+]]></script>
+</div></div><p>You can combine this with any of the other expectations, such 
as, to only match if 3+ messages are done, and were sent to 
the&#160;<strong><code>mock:bar</code></strong> endpoint:</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[NotifyBuilder notify = new 
NotifyBuilder(context)
+    .whenDone(3).wereSentTo(&quot;mock:bar&quot;)
+    .create();
+]]></script>
+</div></div><p>You can add 
additional&#160;<strong><code>wereSentTo</code></strong>'s, such as the 
following two:</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[NotifyBuilder notify = new 
NotifyBuilder(context)
+    
.wereSentTo(&quot;activemq:queue:foo&quot;).wereSentTo(&quot;activemq:queue:bar&quot;)
+    .create();
+]]></script>
+</div></div><p>As well as you can expect a number of messages to be done, and 
a message to fail, which has to be sent to another endpoint:</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[NotifyBuilder notify = new 
NotifyBuilder(context)
+    .whenDone(3).wereSentTo(&quot;activemq:queue:goodOrder&quot;)
+    .and().whenFailed(1).wereSentTo(&quot;activemq:queue:badOrder&quot;)
+    .create();
 ]]></script>
 </div></div></div>
         </td>



Reply via email to