blob: 5898aec469beaa7d72463fa798501f97c6bb96a1 [file] [log] [blame]
<div class="wiki-content maincontent"><h3>Background</h3><p>As well as having a pluggable dispatch policy e.g. round robin, ActiveMQ also supports consumer priorities. This allows us to weight consumers to optimize network hops. For example, you typically want a broker to send messages to regular JMS consumers rather than to other brokers; there's no need to make unnecessary broker-to-broker hops if there are available consumers.</p><h3>Example</h3><p>The priority for a consumer is set using <link><page ri:content-title="Destination Options"></page></link> as follows:</p><structured-macro ac:macro-id="2191e679-8788-42a2-9961-a7799dc2a7e2" ac:name="code" ac:schema-version="1"><parameter ac:name="">java</parameter><plain-text-body>queue = new ActiveMQQueue("TEST.QUEUE?consumer.priority=10");
consumer = session.createConsumer(queue);
</plain-text-body></structured-macro><p>The range of priority values is: <strong><code>0</code></strong> to <strong><code>127</code></strong>. The highest priority is <strong><code>127</code></strong>. The default priority is <strong><code>0</code></strong>.</p><p>The broker orders a queue's consumers according to their priorities, dispatching messages to the highest priority consumers first. Once a particular consumer's prefetch buffer is full the broker will start dispatching messages to the consumer with the next lowest priority whose prefetch buffer is not full.</p></div>