title: Clustering JMS with Spring
body: <p>As a developer I need to have a JMS clustered so that only one node processes a task (task mean queue message) and tasks can be processed by another node when one goes down.</p>
  
  <p>Assumptions:</p>
  
  <ul>
  <li>JMS queue is replicated on a cluster nodes</li>
  <li>task is only processed once (at one node, without distributed queues)</li>
  <li>tasks are continuously processed even when some nodes are taken down</li>
  <li>application can be run on a single node without code changes or recompilation</li>
  </ul>
  
  <p>Application technology stack at the moment:</p>
  
  <p>Web application based on Spring 3.2.X and with embedded ActiveMQ broker which staring during application initialization (&lt; amq:broker />) without persistence. Only this application use created broker. Application running on JBoss 5.0.1.</p>
  
  <p>Now I have to decide which approach we will use for fail-over clustering mentioned above. I was thinking about switch to JBoss messaging (provided by that version of JBoss) but I noticed that this implementation is old and has a lot of bugs.</p>
  
  <p>Currently I hesitate between following possibilities:</p>
  
  <ul>
  <li>embedded ActiveMQ on two JBoss nodes (<a href="http://activemq.apache.org/integrating-apache-activemq-with-jboss.html" rel="nofollow">http://activemq.apache.org/integrating-apache-activemq-with-jboss.html</a>) connected as cluster</li>
  <li>only deploy ActiveMQ to JBoss without integration (I noticed that ActiveMQ 5.9 starts without integration mentioned under above link at activemq-jms-ds.xml and I can connect to JMS directly, without connection factory and JNDI defined at Spring). Am I right ?</li>
  <li>two embedded brokers starting with Spring application on both nodes and connected as cluster (?) Is it possible ?</li>
  <li>separately started two ActiveMQ servers connected as cluster (newer version of ActiveMQ doesn't require container and can run separately)</li>
  </ul>
  
  <p>Which of above could be the best ? Should I do that another way ?</p>
  
  <p>JMS clustering is relatively new for me so all comments / remarks are welcome.</p>