Package org.hornetq.api.core.client.ClientSession

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


         if (jbd != null)
         {
            if (jbd.isQueue())
            {
               QueueQuery response = session.queueQuery(jbd.getSimpleAddress());

               if (!response.isExists())
               {
                  throw new InvalidDestinationException("Queue " + jbd.getName() + " does not exist");
               }
            }
            else
            {
               BindingQuery response = session.bindingQuery(jbd.getSimpleAddress());

               if (!response.isExists())
               {
                  throw new InvalidDestinationException("Topic " + jbd.getName() + " does not exist");
               }
            }
         }
View Full Code Here


      HornetQDestination queue = HornetQDestination.createQueue(queueName);
     
      try
      {
         QueueQuery response = session.queueQuery(queue.getSimpleAddress());

         if (!response.isExists())
         {
            throw new JMSException("There is no queue with name " + queueName);
         }
         else
         {
View Full Code Here

         SimpleString autoDeleteQueueName = null;

         if (dest.isQueue())
         {           
            QueueQuery response = session.queueQuery(dest.getSimpleAddress());

            if (!response.isExists())
            {
               throw new InvalidDestinationException("Queue " + dest.getName() + " does not exist");
            }

            consumer = session.createConsumer(dest.getSimpleAddress(), coreFilterString, false);
         }
         else
         {
            BindingQuery response = session.bindingQuery(dest.getSimpleAddress());

            if (!response.isExists())
            {
               throw new InvalidDestinationException("Topic " + dest.getName() + " does not exist");
            }

            SimpleString queueName;

            if (subscriptionName == null)
            {
               // Non durable sub

               queueName = new SimpleString(UUID.randomUUID().toString());

               session.createTemporaryQueue(dest.getSimpleAddress(), queueName, coreFilterString);

               consumer = session.createConsumer(queueName, null, false);

               autoDeleteQueueName = queueName;
            }
            else
            {
               // Durable sub

               if (connection.getClientID() == null)
               {
                  throw new InvalidClientIDException("Cannot create durable subscription - client ID has not been set");
               }

               if (dest.isTemporary())
               {
                  throw new InvalidDestinationException("Cannot create a durable subscription on a temporary topic");
               }

               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

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

      try
      {
         QueueQuery response = session.queueQuery(queueName);

         if (!response.isExists())
         {
            throw new InvalidDestinationException("Cannot unsubscribe, subscription with name " + name +
                                                  " does not exist");
         }

         if (response.getConsumerCount() != 0)
         {
            throw new IllegalStateException("Cannot unsubscribe durable subscription " + name +
                                            " since it has active subscribers");
         }
View Full Code Here

      {
         throw new InvalidDestinationException("Not a temporary queue " + tempQueue);
      }
      try
      {
         QueueQuery response = session.queueQuery(tempQueue.getSimpleAddress());

         if (!response.isExists())
         {
            throw new InvalidDestinationException("Cannot delete temporary queue " + tempQueue.getName() +
                                                  " does not exist");
         }

         if (response.getConsumerCount() > 0)
         {
            throw new IllegalStateException("Cannot delete temporary queue " + tempQueue.getName() +
                                            " since it has subscribers");
         }
View Full Code Here

               }

               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

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

      try
      {
         QueueQuery response = session.queueQuery(queueName);

         if (!response.isExists())
         {
            throw new InvalidDestinationException("Cannot unsubscribe, subscription with name " + name +
                                                  " does not exist");
         }

         if (response.getConsumerCount() != 0)
         {
            throw new IllegalStateException("Cannot unsubscribe durable subscription " + name +
                                            " since it has active subscribers");
         }
View Full Code Here

      {
         throw new InvalidDestinationException("Not a temporary queue " + tempQueue);
      }
      try
      {
         QueueQuery response = session.queueQuery(tempQueue.getSimpleAddress());

         if (!response.isExists())
         {
            throw new InvalidDestinationException("Cannot delete temporary queue " + tempQueue.getName() +
                                                  " does not exist");
         }

         if (response.getConsumerCount() > 0)
         {
            throw new IllegalStateException("Cannot delete temporary queue " + tempQueue.getName() +
                                            " since it has subscribers");
         }
View Full Code Here

      else
      {
         queue = HornetQDestination.createQueue(queueName);
      }
     
      QueueQuery response = session.queueQuery(queue.getSimpleAddress());

      if (response.isExists())
      {
         return queue;
      }
      else
      {
View Full Code Here

               }

               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

Related Classes of org.hornetq.api.core.client.ClientSession.QueueQuery

Copyright © 2018 www.massapicom. 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.