| <div class="wiki-content maincontent"><h3>Exclusive Consumer</h3> |
| |
| <p>We have a new feature in version 4.x and above called Exclusive Consumer or Exclusive Queues which avoids the end user having to <em>pin</em> anything. The broker will pick a single MessageConsumer to get all the messages for a queue to ensure ordering. If that consumer fails, the broker will auto failover and choose another consumer.</p> |
| |
| <p>So the effect is a heterogeneous cluster where each client has the same setup and configuration; the broker is choosing one consumer to be the <em>master</em> and send all the messages to it in order until it dies; then you get immediate failover to another consumer.</p> |
| |
| <p>For those who've struggled with pinning NMS consumers in clusters you'll immediately realize how useful this is to making clustered, high available distributed services.</p> |
| |
| <h3>Example</h3> |
| |
| <p>An Exclusive Consumer is created using <link><page ri:content-title="ActiveMQ URI Configuration"></page></link> as follows:</p> |
| |
| <structured-macro ac:macro-id="6d35e79c-c27e-418a-b6ef-c047f55c2af0" ac:name="code" ac:schema-version="1"><parameter ac:name="">java</parameter><plain-text-body> |
| var queue = session.GetQueue("TEST.QUEUE?consumer.exclusive=true"); |
| var consumer = session.CreateConsumer(queue); |
| </plain-text-body></structured-macro></div> |
| |