camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r893592 - in /websites/production/camel/content: cache/main.pageCache jgroups.html
Date Fri, 10 Jan 2014 17:19:11 GMT
Author: buildbot
Date: Fri Jan 10 17:19:10 2014
New Revision: 893592

Log:
Production update by buildbot for camel

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

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

Modified: websites/production/camel/content/jgroups.html
==============================================================================
--- websites/production/camel/content/jgroups.html (original)
+++ websites/production/camel/content/jgroups.html Fri Jan 10 17:19:10 2014
@@ -120,14 +120,14 @@ from("jgroups:clusterName").to
 <script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[//
Send message to the cluster named &#39;clusterName&#39;
 from(&quot;direct:start&quot;).to(&quot;jgroups:clusterName&quot;);
 ]]></script>
-</div></div><h3 id="JGroups-Predefinedfilters">Predefined filters</h3><p>JGroups
component comes with predefined filters factory class named <code>JGroupsFilters.</code></p><p>If
you would like to consume only view changes notifications sent to coordinator of the cluster
(and ignore these sent to the "slave" nodes), use the <code>JGroupsFilters.dropNonCoordinatorViews()</code>
filter. This filter is particularly useful when you want a single Camel node to become the
master in the cluster, because messages passing this filter notifies you when given node has
become a coordinator of the cluster. The snippet below demonstrates how to collect only messages
received by the master node.</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
+</div></div><h3 id="JGroups-Predefinedfilters">Predefined filters</h3><p>Starting
from version <strong>2.13.0</strong> of Camel, JGroups component comes with predefined
filters factory class named <code>JGroupsFilters.</code></p><p>If
you would like to consume only view changes notifications sent to coordinator of the cluster
(and ignore these sent to the "slave" nodes), use the <code>JGroupsFilters.dropNonCoordinatorViews()</code>
filter. This filter is particularly useful when you want a single Camel node to become the
master in the cluster, because messages passing this filter notifies you when given node has
become a coordinator of the cluster. The snippet below demonstrates how to collect only messages
received by the master node.</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
 <script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[import
static org.apache.camel.component.jgroups.JGroupsFilters.dropNonCoordinatorViews;
 ...
 from(&quot;jgroups:clusterName?enableViewMessages=true&quot;).
   filter(dropNonCoordinatorViews()).
   to(&quot;seda:masterNodeEventsQueue&quot;);
 ]]></script>
-</div></div><h3 id="JGroups-Predefinedexpressions">Predefined expressions</h3><p>JGroups
component comes with predefined expressions factory class named <code>JGroupsExpressions.</code></p><p>If
you would like to create <a shape="rect" href="delayer.html">delayer</a> that
would affect the route only if the Camel context has not been started yet, use the <code>JGroupsExpressions.delayIfContextNotStarted(long
delay)</code> factory method. The expression created by this factory method will return
given delay value only if the Camel context is in the state different than <code>started</code>.
This expression is particularly useful if you would like to use JGroups component for keeping
singleton (master) route within the cluster. <a shape="rect" href="controlbus-component.html">Control
Bus</a> <code>start</code> command won't initialize the singleton route
if the Camel Context hasn't been yet started. So you need to delay a startup of the master
route, to be sure that it has been initial
 ized after the Camel Context startup. Because such scenario can happen only during the initialization
of the cluster, we don't want to delay startup of the slave node becoming the new master -
that's why we need a conditional delay expression.</p><p>The snippet below demonstrates
how to use conditional delaying with the JGroups component to delay the initial startup of
master node in the cluster.</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+</div></div><h3 id="JGroups-Predefinedexpressions">Predefined expressions</h3><p>Starting
from version <strong>2.13.0</strong> of Camel, JGroups component comes with predefined
expressions factory class named <code>JGroupsExpressions.</code></p><p>If
you would like to create <a shape="rect" href="delayer.html">delayer</a> that
would affect the route only if the Camel context has not been started yet, use the <code>JGroupsExpressions.delayIfContextNotStarted(long
delay)</code> factory method. The expression created by this factory method will return
given delay value only if the Camel context is in the state different than <code>started</code>.
This expression is particularly useful if you would like to use JGroups component for keeping
singleton (master) route within the cluster. <a shape="rect" href="controlbus-component.html">Control
Bus</a> <code>start</code> command won't initialize the singleton route
if the Camel Context hasn't been yet started. So you need to delay a startup 
 of the master route, to be sure that it has been initialized after the Camel Context startup.
Because such scenario can happen only during the initialization of the cluster, we don't want
to delay startup of the slave node becoming the new master - that's why we need a conditional
delay expression.</p><p>The snippet below demonstrates how to use conditional
delaying with the JGroups component to delay the initial startup of master node in the cluster.</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent
pdl">
 <script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[import
static java.util.concurrent.TimeUnit.SECONDS;
 import static org.apache.camel.component.jgroups.JGroupsExpressions.delayIfContextNotStarted;
 import static org.apache.camel.component.jgroups.JGroupsFilters.dropNonCoordinatorViews;
@@ -138,10 +138,23 @@ from(&quot;jgroups:clusterName?enableVie
   to(&quot;controlbus:route?routeId=masterRoute&amp;action=start&amp;async=true&quot;);
 
 from(&quot;timer://master?repeatCount=1&quot;).routeId(&quot;masterRoute&quot;).autoStartup(false).to(masterMockUri); ]]></script>
-</div></div><h3 id="JGroups-Examples">Examples</h3><h4 id="JGroups-Receiveclusterviewchangenotifications">Receive
cluster view change notifications</h4><p>The snippet below demonstrates how to
create the consumer endpoint listening to the&#160;notifications regarding cluster membership
changes. By default only regular messages are consumed by the endpoint.</p><div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><h3 id="JGroups-Examples">Examples</h3><h4 id="JGroups-Sending(receiving)messagesto(from)theJGroupscluster">Sending
(receiving) messages to (from) the JGroups cluster</h4><p>In order to send message
to the JGroups cluster use producer endpoint, just as demonstrated on the snippet below.</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent
pdl">
+<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[from(&quot;direct:start&quot;).to(&quot;jgroups:myCluster&quot;);
+...
+producerTemplate.sendBody(&quot;direct:start&quot;, &quot;msg&quot;)]]></script>
+</div></div><p>To receive the message from the snippet above (on the same
or the other physical machine) listen on the messages coming from the given cluster, just
as demonstrated on the code fragment below.</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[mockEndpoint.setExpectedMessageCount(1);
+mockEndpoint.message(0).body().isEqualTo(&quot;msg&quot;);
+...
+from(&quot;jgroups:myCluster&quot;).to(&quot;mock:messagesFromTheCluster&quot;);
+...
+mockEndpoint.assertIsSatisfied();]]></script>
+</div></div><h4 id="JGroups-Receiveclusterviewchangenotifications">Receive
cluster view change notifications</h4><p>The snippet below demonstrates how to
create the consumer endpoint listening to the&#160;notifications regarding cluster membership
changes. By default only regular messages are consumed by the endpoint.</p><div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[mockEndpoint.setExpectedMessageCount(1);
 mockEndpoint.message(0).body().isInstanceOf(org.jgroups.View.class);
+...
 from(&quot;jgroups:clusterName?enableViewMessages=true&quot;).to(mockEndpoint);
+...
 mockEndpoint.assertIsSatisfied();]]></script>
 </div></div><h4 id="JGroups-Keepingsingletonroutewithinthecluster">Keeping
singleton route within the cluster</h4><p>The snippet below demonstrates how to
keep the singleton consumer route in the cluster of Camel Contexts. As soon as the master
node dies, one of the slaves will be elected as a new master and started. In this particular
example we want to keep singleton <a shape="rect" href="jetty.html">jetty</a>
instance listening for the requests on address<code> <span class="nolink">http://localhost:8080/orders</span></code>.</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent
pdl">
 <script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[import
static java.util.concurrent.TimeUnit.SECONDS;



Mime
View raw message