Examples of QueueQuery


Examples of org.hornetq.api.core.client.ClientSession.QueueQuery

         consumer.close();
         if (activation.getTopicTemporaryQueue() != null)
         {
            // We need to delete temporary topics when the activation is stopped or messages will build up on the server
            SimpleString tmpQueue = activation.getTopicTemporaryQueue();
            QueueQuery subResponse = session.queueQuery(tmpQueue);
            if (subResponse.getConsumerCount() == 0)
            {
               session.deleteQueue(tmpQueue);
            }
         }
      }
View Full Code Here

Examples of org.hornetq.api.core.client.ClientSession.QueueQuery

    }

    static boolean queueExists(final String queueName, final ClientSessionFactory sf) throws HornetQException {
        final ClientSession session = sf.createSession("guest", "guest", false, false, false, false, 1);
        try {
            final QueueQuery query = session.queueQuery(new SimpleString(queueName));
            return query.isExists();
        } finally {
            session.close();
        }
    }
View Full Code Here

Examples of org.hornetq.api.core.client.ClientSession.QueueQuery

         clientSession.createConsumer(queueName);
         clientSession.createConsumer(queueName);
         ClientProducer cp = clientSession.createProducer("a1");
         cp.send(clientSession.createMessage(false));
         cp.send(clientSession.createMessage(false));
         QueueQuery resp = clientSession.queueQuery(new SimpleString(queueName));
         Assert.assertEquals(new SimpleString("a1"), resp.getAddress());
         Assert.assertEquals(2, resp.getConsumerCount());
         Assert.assertEquals(2, resp.getMessageCount());
         Assert.assertEquals(null, resp.getFilterString());
         clientSession.close();
      }
      finally
      {
         if (server.isStarted())
View Full Code Here

Examples of org.hornetq.api.core.client.ClientSession.QueueQuery

         ClientSessionFactory cf = createInVMFactory();
         ClientSession clientSession = cf.createSession(false, true, true);
         clientSession.createQueue("a1", queueName, "foo=bar", false);
         clientSession.createConsumer(queueName);
         clientSession.createConsumer(queueName);
         QueueQuery resp = clientSession.queueQuery(new SimpleString(queueName));
         Assert.assertEquals(new SimpleString("a1"), resp.getAddress());
         Assert.assertEquals(2, resp.getConsumerCount());
         Assert.assertEquals(0, resp.getMessageCount());
         Assert.assertEquals(new SimpleString("foo=bar"), resp.getFilterString());
         clientSession.close();
      }
      finally
      {
         if (server.isStarted())
View Full Code Here

Examples of org.hornetq.api.core.client.ClientSession.QueueQuery

      try
      {
         server.start();
         ClientSessionFactory cf = createInVMFactory();
         ClientSession clientSession = cf.createSession(false, true, true);
         QueueQuery resp = clientSession.queueQuery(new SimpleString(queueName));
         Assert.assertFalse(resp.isExists());
         Assert.assertEquals(null, resp.getAddress());
         clientSession.close();
      }
      finally
      {
         if (server.isStarted())
View Full Code Here

Examples of org.hornetq.api.core.client.ClientSession.QueueQuery

         }

         SimpleString queueName = new SimpleString(HornetQDestination.createQueueNameForDurableSubscription(clientID,
                                                                                                            subscriptionName));

         QueueQuery subResponse = session.queueQuery(queueName);

         if (!subResponse.isExists())
         {
            session.createQueue(activation.getAddress(), queueName, selectorString, true);
         }
         else
         {
            // The check for already exists should be done only at the first session
            // As a deployed MDB could set up multiple instances in order to process messages in parallel.
            if (sessionNr == 0 && subResponse.getConsumerCount() > 0)
            {
               if (!spec.isShareSubscriptions())
               {
                  throw new javax.jms.IllegalStateException("Cannot create a subscriber on the durable subscription since it already has subscriber(s)");
               }
               else if (HornetQRALogger.LOGGER.isDebugEnabled())
               {
                  HornetQRALogger.LOGGER.debug("the mdb on destination " + queueName + " already had " +
                     subResponse.getConsumerCount() +
                     " consumers but the MDB is configured to share subscriptions, so no exceptions are thrown");
               }
            }

            SimpleString oldFilterString = subResponse.getFilterString();

            boolean selectorChanged = selector == null && oldFilterString != null ||
                                      oldFilterString == null &&
                                      selector != null ||
                                      (oldFilterString != null && selector != null && !oldFilterString.toString()
                                                                                                      .equals(selector));

            SimpleString oldTopicName = subResponse.getAddress();

            boolean topicChanged = !oldTopicName.equals(activation.getAddress());

            if (selectorChanged || topicChanged)
            {
View Full Code Here

Examples of org.hornetq.api.core.client.ClientSession.QueueQuery

         consumer.close();
         if (activation.getTopicTemporaryQueue() != null)
         {
            // We need to delete temporary topics when the activation is stopped or messages will build up on the server
            SimpleString tmpQueue = activation.getTopicTemporaryQueue();
            QueueQuery subResponse = session.queueQuery(tmpQueue);
            if (subResponse.getConsumerCount() == 0)
            {
               session.deleteQueue(tmpQueue);
            }
         }
      }
View Full Code Here

Examples of org.hornetq.api.core.client.ClientSession.QueueQuery

         }

         SimpleString queueName = new SimpleString(HornetQDestination.createQueueNameForDurableSubscription(clientID,
                                                                                                            subscriptionName));

         QueueQuery subResponse = session.queueQuery(queueName);

         if (!subResponse.isExists())
         {
            session.createQueue(activation.getAddress(), queueName, selectorString, true);
         }
         else
         {
            // The check for already exists should be done only at the first session
            // As a deployed MDB could set up multiple instances in order to process messages in parallel.
            if (sessionNr == 0 && subResponse.getConsumerCount() > 0)
            {
               if (!spec.isShareSubscriptions())
               {
                  throw new javax.jms.IllegalStateException("Cannot create a subscriber on the durable subscription since it already has subscriber(s)");
               }
               else if (HornetQRALogger.LOGGER.isDebugEnabled())
               {
                  HornetQRALogger.LOGGER.debug("the mdb on destination " + queueName + " already had " +
                     subResponse.getConsumerCount() +
                     " consumers but the MDB is configured to share subscriptions, so no exceptions are thrown");
               }
            }

            SimpleString oldFilterString = subResponse.getFilterString();

            boolean selectorChanged = selector == null && oldFilterString != null ||
                                      oldFilterString == null &&
                                      selector != null ||
                                      (oldFilterString != null && selector != null && !oldFilterString.toString()
                                                                                                      .equals(selector));

            SimpleString oldTopicName = subResponse.getAddress();

            boolean topicChanged = !oldTopicName.equals(activation.getAddress());

            if (selectorChanged || topicChanged)
            {
View Full Code Here

Examples of org.hornetq.api.core.client.ClientSession.QueueQuery

         consumer.close();
         if (activation.getTopicTemporaryQueue() != null)
         {
            // We need to delete temporary topics when the activation is stopped or messages will build up on the server
            SimpleString tmpQueue = activation.getTopicTemporaryQueue();
            QueueQuery subResponse = session.queueQuery(tmpQueue);
            if (subResponse.getConsumerCount() == 0)
            {
               session.deleteQueue(tmpQueue);
            }
         }
      }
View Full Code Here

Examples of org.hornetq.api.core.client.ClientSession.QueueQuery

               }

               queueName = new SimpleString(HornetQDestination.createQueueNameForDurableSubscription(connection.getClientID(),
                                                                                                     subscriptionName));

               QueueQuery subResponse = session.queueQuery(queueName);

               if (!subResponse.isExists())
               {
                  session.createQueue(dest.getSimpleAddress(), queueName, coreFilterString, true);
               }
               else
               {
                  // Already exists
                  if (subResponse.getConsumerCount() > 0)
                  {
                     throw new IllegalStateException("Cannot create a subscriber on the durable subscription since it already has subscriber(s)");
                  }

                  // From javax.jms.Session Javadoc (and also JMS 1.1 6.11.1):
                  // A client can change an existing durable subscription by
                  // creating a durable
                  // TopicSubscriber with the same name and a new topic and/or
                  // message selector.
                  // Changing a durable subscriber is equivalent to
                  // unsubscribing (deleting) the old
                  // one and creating a new one.

                  SimpleString oldFilterString = subResponse.getFilterString();

                  boolean selectorChanged = coreFilterString == null && oldFilterString != null ||
                                            oldFilterString == null &&
                                            coreFilterString != null ||
                                            oldFilterString != null &&
                                            coreFilterString != null &&
                                            !oldFilterString.equals(coreFilterString);

                  SimpleString oldTopicName = subResponse.getAddress();

                  boolean topicChanged = !oldTopicName.equals(dest.getSimpleAddress());

                  if (selectorChanged || topicChanged)
                  {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.