blob: d0de7e0bc97c023e2b105a690c075d2dba1a8fd9 [file] [log] [blame]
<div class="wiki-content maincontent"><p>This is much simpler and more powerful in ActiveMQ 4.0 - you can configure different <link><page ri:content-title="Dispatch Policies"></page></link> directly. </p>
<p>For now in ActiveMQ 3.x we have a <link><page ri:content-title="What is the Prefetch Limit For?"></page><link-body>PrefetchPolicy configuration</link-body></link>. This allows a certain number of messages to be dispatched to a consumer before they are acknowledged. This feature is to achieve high performance; the higher the value the less likely it is that a client has to wait for messages to arrive before processing the message and so the higher the throughput.</p>
<p>e.g. under heavy load of a busy system you probably want to dispatch 1000 or so messages to a consumer, so as soon as its ready to receive a message, there are a bunch of them in memory waiting to be used - rather than having a slow request-response RPC each time.</p>
<p>However the effect of this is that when you send a small number of messages, they tend to all go to one consumer unless you've lots of messages. Note that this issue can be avoided in 4.x as there is now a configurable DispatchPolicy so that you can enforce, say, round robin dispatch policy to ensure that messages are dispatched fairly to avoid this issue. </p>
<p>In ActiveMQ 3.x or later a work around for this issue is to reconfigure the PrefetchPolicy on the ConnectionFactory/Connection so that the broker only prefetches a single message per consumer; though this will greatly reduce the performance and throughput of the system.</p>
<h3>Configuring the dispatch policy in ActiveMQ 4.x</h3>
<p>In AMQ 4.x, the dispatch policy can now be configured on the xml configuration file (ie. activemq.xml)<br clear="none">
ie.</p>
<structured-macro ac:macro-id="b215a33e-7bd9-4d85-83b6-523f38286caa" ac:name="code" ac:schema-version="1"><plain-text-body>
&lt;destinationPolicy&gt;
&lt;policyMap&gt;&lt;policyEntries&gt;
&lt;policyEntry topic="COMMAND.&gt;"&gt;
&lt;dispatchPolicy&gt;
&lt;strictOrderDispatchPolicy /&gt;
&lt;/dispatchPolicy&gt;
&lt;subscriptionRecoveryPolicy&gt;
&lt;noSubscriptionRecoveryPolicy /&gt;
&lt;/subscriptionRecoveryPolicy&gt;
&lt;/policyEntry&gt;
&lt;/policyEntries&gt;&lt;/policyMap&gt;
&lt;/destinationPolicy&gt;
</plain-text-body></structured-macro></div>