Package org.jboss.jms.server.destination

Examples of org.jboss.jms.server.destination.ManagedDestination


         if (closed)
         {
            throw new IllegalStateException("Session is closed");
         }
        
         ManagedDestination dest = (ManagedDestination)dm.getDestination(name, true);
        
         if (dest == null)
         {
            throw new JMSException("There is no administratively defined queue with name:" + name);
         }       
  
         return new JBossQueue(dest.getName());
      }
      catch (Throwable t)
      {
         throw ExceptionUtil.handleJMSInvocation(t, this + " createQueue");
      }
View Full Code Here


         if (closed)
         {
            throw new IllegalStateException("Session is closed");
         }
        
         ManagedDestination dest = (ManagedDestination)dm.getDestination(name, false);
                 
         if (dest == null)
         {
            throw new JMSException("There is no administratively defined topic with name:" + name);
         }       
View Full Code Here

           
            Queue queue = binding.getQueue();
           
            JMSCondition cond = (JMSCondition)binding.getCondition();                       
           
            ManagedDestination dest =
               sp.getDestinationManager().getDestination(cond.getName(), cond.isQueue());
           
            if (dest == null)
            {
               throw new IllegalStateException("Cannot find managed destination with name " +
                  cond.getName() + " isQueue" + cond.isQueue());
            }
           
            Queue dlqToUse =
               dest.getDLQ() == null ? defaultDLQ : dest.getDLQ();
           
            Queue expiryQueueToUse =
               dest.getExpiryQueue() == null ? defaultExpiryQueue : dest.getExpiryQueue();
           
            List dels = queue.recoverDeliveries(ids);
           
            Iterator iter2 = dels.iterator();
           
            Iterator iter3 = acks.iterator();
           
            while (iter2.hasNext())
            {
               Delivery del = (Delivery)iter2.next();
              
               DeliveryRecovery info = (DeliveryRecovery)iter3.next();
              
               long deliveryId = info.getDeliveryID();
              
               maxDeliveryId = Math.max(maxDeliveryId, deliveryId);
              
               if (trace) { log.trace(this + " Recovered delivery " + deliveryId + ", " + del); }
              
               deliveries.put(new Long(deliveryId),
                              new DeliveryRecord(del, -1, dlqToUse,
                                                 expiryQueueToUse, dest.getRedeliveryDelay()));
            }
         }
        
         this.deliveryIdSequence = new SynchronizedLong(maxDeliveryId + 1);
      }
View Full Code Here

         connectionEndpoint.addTemporaryDestination(dest);
        
         // Register with the destination manager
        
         ManagedDestination mDest;
        
         int fullSize = connectionEndpoint.getDefaultTempQueueFullSize();
         int pageSize = connectionEndpoint.getDefaultTempQueuePageSize();
         int downCacheSize = connectionEndpoint.getDefaultTempQueueDownCacheSize();
        
View Full Code Here

         {
            throw new InvalidDestinationException("Destination:" + dest +
               " is not a temporary destination");
         }
        
         ManagedDestination mDest = dm.getDestination(dest.getName(), dest.isQueue());
        
         if (mDest == null)
         {
            throw new InvalidDestinationException("No such destination: " + dest);
         }
View Full Code Here

        
         JMSCondition topicCond = (JMSCondition)binding.getCondition();
        
         String topicName = topicCond.getName();
        
         ManagedDestination mDest = dm.getDestination(topicName, false);
        
         //Unbind it
   
         if (mDest.isClustered() && !postOffice.isLocal())
         {
            ClusteredPostOffice cpo = (ClusteredPostOffice)postOffice;
           
            cpo.unbindClusteredQueue(queueName);
         }
View Full Code Here

            (selectorString == null ? "" : ", selector '" + selectorString + "'") +
            (subscriptionName == null ? "" : ", subscription '" + subscriptionName + "'") +
            (noLocal ? ", noLocal" : ""));
      }

      ManagedDestination mDest = dm.
         getDestination(jmsDestination.getName(), jmsDestination.isQueue());
     
      if (mDest == null)
      {
         throw new InvalidDestinationException("No such destination: " + jmsDestination);
      }
     
      if (jmsDestination.isTemporary())
      {
         // Can only create a consumer for a temporary destination on the same connection
         // that created it
         if (!connectionEndpoint.hasTemporaryDestination(jmsDestination))
         {
            String msg = "Cannot create a message consumer on a different connection " +
                         "to that which created the temporary destination";
            throw new IllegalStateException(msg);
         }
      }
     
      int consumerID = connectionEndpoint.getServerPeer().getNextObjectID();
     
      Binding binding = null;
     
      // Always validate the selector first
      Selector selector = null;
      if (selectorString != null)
      {
         selector = new Selector(selectorString);
      }
     
      if (jmsDestination.isTopic())
      {
         JMSCondition topicCond = new JMSCondition(false, jmsDestination.getName());
        
         if (subscriptionName == null)
         {
            // non-durable subscription
            if (log.isTraceEnabled()) { log.trace(this + " creating new non-durable subscription on " + jmsDestination); }
           
            // Create the non durable sub
                       
            PagingFilteredQueue q;
           
            if (postOffice.isLocal() || !mDest.isClustered())
            {
               q = new PagingFilteredQueue(new GUID().toString(), idm.getID(), ms, pm, true, false,
                        mDest.getMaxSize(), selector,
                        mDest.getFullSize(),
                        mDest.getPageSize(),
                        mDest.getDownCacheSize());
              
               binding = postOffice.bindQueue(topicCond, q);
            }
            else
           
               q = new LocalClusteredQueue((ClusteredPostOffice)postOffice, nodeId, new GUID().toString(),
                                           idm.getID(), ms, pm, true, false,
                                           mDest.getMaxSize(), selector, tr,
                                           mDest.getFullSize(),
                                           mDest.getPageSize(),
                                           mDest.getDownCacheSize());
              
               ClusteredPostOffice cpo = (ClusteredPostOffice)postOffice;

               binding = cpo.bindClusteredQueue(topicCond, (LocalClusteredQueue)q);
            }
            String counterName = TopicService.SUBSCRIPTION_MESSAGECOUNTER_PREFIX + q.getName();
 
            int dayLimitToUse = mDest.getMessageCounterHistoryDayLimit();
            if (dayLimitToUse == -1)
            {
               //Use override on server peer
               dayLimitToUse = sp.getDefaultMessageCounterHistoryDayLimit();
            }
           
            MessageCounter counter =
               new MessageCounter(counterName, null, q, true, false,
                                  dayLimitToUse);
           
            sp.getMessageCounterManager().registerMessageCounter(counterName, counter);
         }
         else
         {
            if (jmsDestination.isTemporary())
            {
               throw new InvalidDestinationException("Cannot create a durable subscription on a temporary topic");
            }
           
            // We have a durable subscription, look it up
            String clientID = connectionEndpoint.getClientID();
            if (clientID == null)
            {
               throw new JMSException("Cannot create durable subscriber without a valid client ID");
            }
           
            // See if there any bindings with the same client_id.subscription_name name
           
            String name = MessageQueueNameHelper.createSubscriptionName(clientID, subscriptionName);
           
            binding = postOffice.getBindingForQueueName(name);
           
            if (binding == null)
            {
               // Does not already exist
              
               if (trace) { log.trace(this + " creating new durable subscription on " + jmsDestination); }
                             
               PagingFilteredQueue q;

               if (postOffice.isLocal())
               {
                  q = new PagingFilteredQueue(name, idm.getID(), ms, pm, true, true,
                                              mDest.getMaxSize(), selector,
                                              mDest.getFullSize(),
                                              mDest.getPageSize(),
                                              mDest.getDownCacheSize());

                  binding = postOffice.bindQueue(topicCond, q);
               }
               else
               {
                  q = new LocalClusteredQueue((ClusteredPostOffice)postOffice, nodeId, name, idm.getID(),
                                              ms, pm, true, true,
                                              mDest.getMaxSize(), selector, tr,
                                              mDest.getFullSize(),
                                              mDest.getPageSize(),
                                              mDest.getDownCacheSize());
                 
                  ClusteredPostOffice cpo = (ClusteredPostOffice)postOffice;
                 
                  if (mDest.isClustered())
                  {
                     binding = cpo.bindClusteredQueue(topicCond, (LocalClusteredQueue)q);
                  }
                  else
                  {
                     binding = cpo.bindQueue(topicCond, q);
                  }
               }
               String counterName = TopicService.SUBSCRIPTION_MESSAGECOUNTER_PREFIX + q.getName();
                      
               MessageCounter counter =
                  new MessageCounter(counterName, subscriptionName, q, true, true,
                                     mDest.getMessageCounterHistoryDayLimit());
              
               sp.getMessageCounterManager().registerMessageCounter(counterName, counter);
            }
            else
            {
               //Durable sub already exists
              
               if (trace) { log.trace(this + " subscription " + subscriptionName + " already exists"); }
              
               // 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.
              
               String filterString =
                  binding.getQueue().getFilter() != null ?
                     binding.getQueue().getFilter().getFilterString() : null;
              
               boolean selectorChanged =
                  (selectorString == null && filterString != null) ||
                  (filterString == null && selectorString != null) ||
                  (filterString != null && selectorString != null &&
                           !filterString.equals(selectorString));
              
               if (trace) { log.trace("selector " + (selectorChanged ? "has" : "has NOT") + " changed"); }
              
               JMSCondition cond = (JMSCondition)binding.getCondition();
              
               boolean topicChanged = !cond.getName().equals(jmsDestination.getName());
              
               if (log.isTraceEnabled()) { log.trace("topic " + (topicChanged ? "has" : "has NOT") + " changed"); }
              
               if (selectorChanged || topicChanged)
               {
                  if (trace) { log.trace("topic or selector changed so deleting old subscription"); }
                 
                  // Unbind the durable subscription
                 
                  if (mDest.isClustered() && !postOffice.isLocal())
                  {
                     ClusteredPostOffice cpo = (ClusteredPostOffice)postOffice;
                    
                     cpo.unbindClusteredQueue(name);
                  }
                  else
                  {
                     postOffice.unbindQueue(name);
                  }
                 
                  // create a fresh new subscription
                                   
                  PagingFilteredQueue q;
                 
                  if (postOffice.isLocal())
                  {
                     q = new PagingFilteredQueue(name, idm.getID(), ms, pm, true, true,
                              mDest.getMaxSize(), selector,
                              mDest.getFullSize(),
                              mDest.getPageSize(),
                              mDest.getDownCacheSize());
                     binding = postOffice.bindQueue(topicCond, q);
                  }
                  else
                  {
                     q = new LocalClusteredQueue((ClusteredPostOffice)postOffice, nodeId, name, idm.getID(), ms, pm, true, true,
                              mDest.getMaxSize(), selector, tr,
                              mDest.getFullSize(),
                              mDest.getPageSize(),
                              mDest.getDownCacheSize());
                    
                     ClusteredPostOffice cpo = (ClusteredPostOffice)postOffice;
                    
                     if (mDest.isClustered())
                     {
                        binding = cpo.bindClusteredQueue(topicCond, (LocalClusteredQueue)q);
                     }
                     else
                     {
                        binding = cpo.bindQueue(topicCond, (LocalClusteredQueue)q);
                     }
                  }
                  String counterName = TopicService.SUBSCRIPTION_MESSAGECOUNTER_PREFIX + q.getName();
                 
                  MessageCounter counter =
                     new MessageCounter(counterName, subscriptionName, q, true, true,
                                        mDest.getMessageCounterHistoryDayLimit());
                 
                  sp.getMessageCounterManager().registerMessageCounter(counterName, counter);
               }
            }
         }
      }
      else
      {
         // Consumer on a jms queue
        
         // Let's find the binding
         binding = postOffice.getBindingForQueueName(jmsDestination.getName());
        
         if (binding == null)
         {
            throw new IllegalStateException("Cannot find binding for jms queue: " + jmsDestination.getName());
         }
      }
     
      int prefetchSize = connectionEndpoint.getPrefetchSize();
     
      Queue dlqToUse = mDest.getDLQ() == null ? defaultDLQ : mDest.getDLQ();
     
      Queue expiryQueueToUse = mDest.getExpiryQueue() == null ? defaultExpiryQueue : mDest.getExpiryQueue();
     
      long redeliveryDelay = mDest.getRedeliveryDelay();
     
      if (redeliveryDelay == 0)
      {
         redeliveryDelay = sp.getDefaultRedeliveryDelay();
      }
View Full Code Here

   public synchronized void unregisterDestination(ManagedDestination destination) throws Exception
   {
      String jndiName = null;
      if (destination.isQueue())
      {
         ManagedDestination dest = (ManagedDestination)queueMap.remove(destination.getName());
         if (dest != null)
         {
            jndiName = dest.getJndiName();
         }
      }
      else
      {
         ManagedDestination dest = (ManagedDestination)topicMap.remove(destination.getName());
         if (dest != null)
         {
            jndiName = dest.getJndiName();
         }
      }
      if (jndiName == null)
      {
         return;
View Full Code Here

  
   public synchronized ManagedDestination getDestination(String name, boolean isQueue)
   {
      Map m = isQueue ? queueMap : topicMap;
     
      ManagedDestination holder = (ManagedDestination)m.get(name);
     
      return holder;
   }
View Full Code Here

      Set destinations = new HashSet();
     
      Iterator iter = queueMap.values().iterator();
      while (iter.hasNext())
      {
         ManagedDestination dest = (ManagedDestination)iter.next();
         if (dest.isTemporary())
         {
            destinations.add(new JBossTemporaryQueue(dest.getName()));
         }
         else
         {
            destinations.add(new JBossQueue(dest.getName()));
         }
      }
     
      iter = topicMap.values().iterator();
      while (iter.hasNext())
      {
         ManagedDestination dest = (ManagedDestination)iter.next();
         if (dest.isTemporary())
         {
            destinations.add(new JBossTemporaryTopic(dest.getName()));
         }
         else
         {
            destinations.add(new JBossTopic(dest.getName()));
         }
      }
     
      return destinations;
   }
View Full Code Here

TOP

Related Classes of org.jboss.jms.server.destination.ManagedDestination

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.