activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Torsten Mielke (Confluence)" <conflue...@apache.org>
Subject [CONF] Apache ActiveMQ > Dispatch Policies
Date Thu, 14 Nov 2013 08:46:02 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/en/2176/1/1/_/styles/combined.css?spaceKey=ACTIVEMQ&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/ACTIVEMQ/Dispatch+Policies">Dispatch
Policies</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~tmielke">Torsten
Mielke</a>
    </h4>
        <div id="versionComment">
        <b>Comment:</b>
        broken url in {snippet}. Corrected but still pointing to svn repo, not yet to git.<br
/>
    </div>
        <br/>
                         <h4>Changes (2)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >The default org.apache.activemq.broker.region.policy.SimpleDispatchPolicy
does what one would expect and delivers messages to all subscribers. An example of a more
advanced implementation is the org.apache.activemq.broker.region.policy.PriorityNetworkDispatchPolicy
which will only dispatch to the highest priority network consumer. This is useful in a loop
network topology where there is more than route to a consumer. <br> <br></td></tr>
            <tr><td class="diff-changed-lines" >Here is an [example of destination
policy <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">configuration|http://svn.apache.org/repos/asf/activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/xbean/activemq-policy.xml].</span>
<span class="diff-added-words"style="background-color: #dfd;">configuration|http://svn.apache.org/repos/asf/activemq/trunk/activemq-unit-tests/src/test/resources/org/apache/activemq/xbean/activemq-policy.xml].</span>
<br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">{snippet:id=xbean|lang=xml|url=activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/xbean/activemq-policy.xml}</span>
<span class="diff-added-words"style="background-color: #dfd;">{snippet:id=xbean|lang=xml|url=activemq/trunk/activemq-unit-tests/src/test/resources/org/apache/activemq/xbean/activemq-policy.xml}</span>
<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h1><a name="DispatchPolicies-DispatchPolicies"></a>Dispatch Policies</h1>

<h2><a name="DispatchPolicies-Dispatchpoliciesforqueues"></a>Dispatch policies
for queues</h2>

<p>Plug-able dispatch policies only apply to topics. For Queues, dispatch is more static,
you can choose round robin (the default) or strict order. Before discussing dispatch policies
its worth first understanding <a href="/confluence/display/ACTIVEMQ/What+is+the+prefetch+limit+for"
title="What is the prefetch limit for">the purpose of the prefetch value</a>.</p>

<p>The out of the box configuration of ActiveMQ is designed for high performance and
high throughput messaging where there are lots of messages that need to be dispatched to consumers
as quickly as possible. So the default prefetch values are fairly large and the default dispatch
policy will try and fill the prefetch buffers as quickly as possible.</p>

<p>However with messaging there are many use cases and sometimes the default configuration
is not ideal to your use case; when you send a small number of messages, they tend to all
go to one consumer unless you've lots of messages.  If you have a large number of consumers
and a relatively high <a href="/confluence/display/ACTIVEMQ/What+is+the+prefetch+limit+for"
title="What is the prefetch limit for">prefetch value</a> and you have a small number
of messages that each message takes quite a while to process then the default dispatch policy
might result in increasing the amount of time it takes to process all the messages (since
the load balancing is not fair for small numbers of messages).</p>

<p>For queues, you can define whether the dispatch will occur in a round-robin fashion
(default behavior) or if one consumer's prefetch buffer will be exhausted before the dispatch
process selects the next consumer along (strictOrderDispatch).<br/>
The latter behaviour is enabled by setting the "strictOrderDispatch" attribute on the &lt;policyEntry
/&gt; element. E.g.:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">&lt;policyEntry queue="&gt;" strictOrderDispatch="false"
/&gt; </pre>
</div></div>
<p>Consumer priorities are observed, so if you have several consumers with different
<a href="http://activemq.apache.org/consumer-priority.html" class="external-link" rel="nofollow">priorities</a>,
the one with the highest priority will be flooded first until it can take no more, then the
next one along, etc</p>

<h2><a name="DispatchPolicies-DispatchpoliciesforTopics"></a>Dispatch policies
for Topics</h2>
<p>There are more options for topics because the dispatch policy is plug-able. Any implementation
of org.apache.activemq.broker.region.policy.DispatchPolicy will work.<br/>
The default org.apache.activemq.broker.region.policy.SimpleDispatchPolicy does what one would
expect and delivers messages to all subscribers. An example of a more advanced implementation
is the org.apache.activemq.broker.region.policy.PriorityNetworkDispatchPolicy which will only
dispatch to the highest priority network consumer. This is useful in a loop network topology
where there is more than route to a consumer.</p>

<p>Here is an <a href="http://svn.apache.org/repos/asf/activemq/trunk/activemq-unit-tests/src/test/resources/org/apache/activemq/xbean/activemq-policy.xml"
class="external-link" rel="nofollow">example of destination policy configuration</a>.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<script type="syntaxhighlighter" class="theme: Default; brush: xml; gutter: false"><![CDATA[
&lt;beans 
  xmlns="http://www.springframework.org/schema/beans" 
  xmlns:amq="http://activemq.apache.org/schema/core"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
  http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd"&gt;

  &lt;bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/&gt;

  &lt;broker persistent="false" brokerName="${brokername}" xmlns="http://activemq.apache.org/schema/core"&gt;

    &lt;!--  lets define the dispatch policy --&gt;
    &lt;destinationPolicy&gt;
      &lt;policyMap&gt;
        &lt;policyEntries&gt;
          &lt;policyEntry topic="FOO.&gt;"&gt;
            &lt;dispatchPolicy&gt;
              &lt;roundRobinDispatchPolicy /&gt;
            &lt;/dispatchPolicy&gt;
            &lt;subscriptionRecoveryPolicy&gt;
              &lt;lastImageSubscriptionRecoveryPolicy /&gt;
            &lt;/subscriptionRecoveryPolicy&gt;
          &lt;/policyEntry&gt;

          &lt;policyEntry topic="ORDERS.&gt;"&gt;
            &lt;dispatchPolicy&gt;
              &lt;strictOrderDispatchPolicy /&gt;
            &lt;/dispatchPolicy&gt;
            &lt;!--  1 minutes worth --&gt;
            &lt;subscriptionRecoveryPolicy&gt;
              &lt;timedSubscriptionRecoveryPolicy recoverDuration="60000" /&gt;
            &lt;/subscriptionRecoveryPolicy&gt;
          &lt;/policyEntry&gt;

          &lt;policyEntry topic="PRICES.&gt;"&gt;

            &lt;!-- lets force old messages to be discarded for slow consumers --&gt;
            &lt;pendingMessageLimitStrategy&gt;
              &lt;constantPendingMessageLimitStrategy limit="10"/&gt;
            &lt;/pendingMessageLimitStrategy&gt;

            &lt;!--  10 seconds worth --&gt;
            &lt;subscriptionRecoveryPolicy&gt;
              &lt;timedSubscriptionRecoveryPolicy recoverDuration="10000" /&gt;
            &lt;/subscriptionRecoveryPolicy&gt;
            
          &lt;/policyEntry&gt;
          &lt;policyEntry tempTopic="true" advisoryForConsumed="true" /&gt;

          &lt;policyEntry tempQueue="true" advisoryForConsumed="true" /&gt;
        &lt;/policyEntries&gt;
      &lt;/policyMap&gt;
    &lt;/destinationPolicy&gt;
  &lt;/broker&gt;

&lt;/beans&gt;
]]></script>
</div></div>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;" class="grey">
                        <a href="https://cwiki.apache.org/confluence/users/removespacenotification.action?spaceKey=ACTIVEMQ">Stop
watching space</a>
            <span style="padding: 0px 5px;">|</span>
                <a href="https://cwiki.apache.org/confluence/users/editmyemailsettings.action">Change
email notification preferences</a>
</div>
        <a href="https://cwiki.apache.org/confluence/display/ACTIVEMQ/Dispatch+Policies">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=35950&revisedVersion=9&originalVersion=8">View
Changes</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message