1 Reply Latest reply on Aug 6, 2010 4:32 AM by Jeff Mesnil

    Clustering programmatically created queues fails.

    Joe Schmoe Newbie

      I have a HornetQ cluster setup between two nodes, and clustering is working fine on queues statically defined in hornetq-configuration.xml.

       

      However, I also need to cluster programatically created queues that match the address-setting in the cluster configuration.  However, it does not appear to be working even when I am also creating the queue on the second node.

       

      Here is the configuration for the cluster in the hornetq-configuration.xml:

       

      <cluster-connections>
                <!-- Task queue cluster. -->
            <cluster-connection name="lf-cluster">
               <address>jms.queue.tasks</address>
               <retry-interval>500</retry-interval>
               <use-duplicate-detection>true</use-duplicate-detection>
               <forward-when-no-consumers>false</forward-when-no-consumers>
               <max-hops>1</max-hops>
               <discovery-group-ref discovery-group-name="lf-discovery-group" />
            </cluster-connection>
         </cluster-connections>
      
      
      

       

      I am programmatically creating the queues like so:

       

       

      Session session = null;
                try {
                     Queue managementQueue = new HornetQQueue("hornetq.management");
                     session = taskQueueConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
                     QueueRequestor requestor = new QueueRequestor((QueueSession) session, managementQueue);
                     Message msg = session.createMessage();
                     JMSManagementHelper.putOperationInvocation(msg, "jms.server",
                                "createQueue", JMS_QUEUE_NAME_PREFIX + task.getQueueName(), JMS_QUEUE_JNDI_PREFIX + task.getQueueName());
                     Message reply = requestor.request(msg);
                     boolean success = JMSManagementHelper.hasOperationSucceeded(reply);
                     if (!success)
                          throw new RuntimeException("Unable to open queue tasks because the queue could not be created.");
                     // Replicate queue to node 2.
                     replicateTaskQueue(task);
                } catch (JMSException e) {
                     String msg = "Fatal JMSException caught attempting to create task queue!!";
                     log.fatal(msg, e);
                     throw new RuntimeException(msg, e);
                } finally {
                     if (session != null) { try { session.close(); } catch (JMSException e) {} }
                }
      

       

       

      The full queue name the code above is creating will be:  jms.queue.tasks.taskQueue1.  I would expect the address on the cluster configuration to match and to start clustering that queue.

       

      And yes, there are consumers on the node2 queue.

       

      Am I missing something here?