<p>This example shows you how can use shared consumers to share a subscription on a topic. In JMS 1.1 this was not allowed
and so caused a scalability issue. In JMS 2 this restriction has been lifted so you can share the load across different
threads and connections.</p>
<h2>Example step-by-step</h2>
<p><i>To run the example, simply type <code>mvn verify</code> from this directory</i></p>
<ol>
<li>First we need to get an initial context so we can look-up the JMS connection factory and destination objects from JNDI. This initial context will get it's properties from the <code>client-jndi.properties</code> file in the directory <code>../common/config</code></li>
producer.send(topic, "this is a second String!") ;</code>
</pre>
<li>we then receive the 2 messages using both shared consumers</li>
<preclass="prettyprint">
<code>
String body = jmsConsumer.receiveBody(String.class, 5000);
body = jmsConsumer2.receiveBody(String.class, 5000);</code>
</pre>
<li>And finally, <b>always</b> remember to close your JMS connections and resources after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>