Package org.jboss.messaging.core.contract

Examples of org.jboss.messaging.core.contract.Queue


     {
       //This is ok - maybe new failover node but queue is not yet deployed
       return;
     }
    
     Queue queue = binding.queue;
    
     queue.removeFromRecoveryArea(nodeID, messageID)
   }
View Full Code Here


         throw new IllegalArgumentException("Binding is null");
      }
    
     Condition condition = binding.condition;
    
     Queue queue = binding.queue;
    
     if (queue == null)
      {
         throw new IllegalArgumentException("Queue is null");
      }
    
     if (queue.getNodeID() != thisNodeID)
     {
       throw new IllegalArgumentException("Cannot bind a queue from another node");
     }

      if (condition == null)
      {
         throw new IllegalArgumentException("Condition is null");
      }
          
     //The binding might already exist - this could happen if the queue is bind all simultaneously from more than one node of the cluster
      boolean added = addBindingInMemory(binding);   
     
      if (added)
      {
        if (queue.isRecoverable())
        {
          // Need to write the mapping to the database
          insertBindingInStorage(condition, queue, binding.allNodes);
        }
       
        if (clustered && queue.isClustered())
         {
           String filterString = queue.getFilter() == null ? null : queue.getFilter().getFilterString();       
          
           MappingInfo info = new MappingInfo(thisNodeID, queue.getName(), condition.toText(), filterString, queue.getChannelID(),
                                            queue.isRecoverable(), true,
                                            binding.allNodes,
                                            queue.getFullSize(), queue.getPageSize(), queue.getDownCacheSize(),
                                            queue.getMaxSize(),
                                            queue.getRecoverDeliveriesTimeout());
          
            ClusterRequest request = new BindRequest(info, allNodes);

            groupMember.multicastControl(request, sync);
         }       
View Full Code Here

      Binding removed = removeBindingInMemory(thisNodeID, queueName);

      //The queue might not be removed (it's already removed) if two unbind all requests are sent simultaneously on the cluster
      if (removed != null)
      {
        Queue queue = removed.queue;

        Condition condition = removed.condition;

        if (queue.isRecoverable())
        {
           //Need to remove from db too

           deleteBindingFromStorage(queue);
        }

        if (clustered && queue.isClustered())
        {
          String filterString = queue.getFilter() == null ? null : queue.getFilter().getFilterString();

          MappingInfo info = new MappingInfo(thisNodeID, queue.getName(), condition.toText(), filterString, queue.getChannelID(),
                                           queue.isRecoverable(), true, allNodes);

          UnbindRequest request = new UnbindRequest(info, allNodes);

          groupMember.multicastControl(request, sync);
        }

         queue.removeAllReferences();

      }

      return removed;
   }
View Full Code Here

          
           List targets = new ArrayList();
          
           while (iter.hasNext())
           {
             Queue queue = (Queue)iter.next();
            
             if (trace) { log.trace(this + " considering queue " + queue); }
            
             if (queue.getNodeID() == thisNodeID)
             {
               if (trace) { log.trace(this + " is a local queue"); }
            
               //Local queue

               boolean routeLocal = false;
              
               if (!fromCluster)
               {
                 //Same node
                 routeLocal = true;
               }
               else
               {
                 //From the cluster
                 if (!queue.isRecoverable() && queue.isClustered())
                 {
                   //When routing from the cluster we only route to non recoverable queues
                   //who haven't already been routed to on the sending node (same name)
                   //Also we don't route to non clustered queues
                   if (names == null || !names.contains(queue.getName()))
                   {
                     routeLocal = true;
                   }
                 }
               }
              
               if (routeLocal)
               {
                 //If we're not routing from the cluster OR the queue is unreliable then we consider it
                
                 //When we route from the cluster we never route to reliable queues
                
                 Filter filter = queue.getFilter();
                
                 if (filter == null || filter.accept(ref.getMessage()))
                 {                   
                   if (trace) { log.trace(this + " Added queue " + queue + " to list of targets"); }
                  
                  targets.add(queue);
                 
                  if (ref.getMessage().isReliable() && queue.isRecoverable())
                   {
                     localReliableCount++;
                   }                
                 }  
               }
             }
             else if (!fromCluster)
             {
               //Remote queue
              
               if (trace) { log.trace(this + " is a remote queue"); }
              
               if (!queue.isRecoverable() && queue.isClustered())
               {                
                 //When we send to the cluster we never send to reliable queues
                
                 Filter filter = queue.getFilter();
                
                 if (filter == null || filter.accept(ref.getMessage()))
                 {
                   if (remoteSet == null)
                   {
                     remoteSet = new HashSet();
                   }
                  
                   remoteSet.add(new Integer(queue.getNodeID()));
                  
                   if (trace) { log.trace(this + " added it to the remote set for casting"); }
                 }
               }
               else
               {
                 if (trace) { log.trace(this + " is recoverable so not casting"); }
               }
             }
           }
                                
           //If the ref is reliable and there is more than one reliable local queue that accepts the message then we need
           //to route in a transaction to guarantee once and only once reliability guarantee
          
           boolean startedTx = false;
          
           if (tx == null && localReliableCount > 1)
           {
             if (trace) { log.trace("Starting internal tx, reliableCount = " + localReliableCount); }
            
             tx = tr.createTransaction();
            
             startedTx = true;
           }
          
           //Now actually route the ref
          
           iter = targets.iterator();
          
           Set queueNames = null;
          
           while (iter.hasNext())
           {
             Queue queue = (Queue)iter.next();
            
             if (trace) { log.trace(this + " Routing ref to queue " + queue); }
                       
             Delivery del = queue.handle(null, ref, tx);
            
             if (trace) { log.trace("Queue returned " + del); }

               if (del != null && del.isSelectorAccepted())
               {
                  routed = true;
                 
                  if (remoteSet != null)
                  {
                    if (queueNames == null)
                    {
                      queueNames = new HashSet();
                    }
                   
                    //We put the queue name in a set - this is used on other nodes after routing from the cluster so it
                    //doesn't route to queues with the same name on other nodes
                    queueNames.add(queue.getName());
                  }
               }
           }
                      
            if (remoteSet != null)
View Full Code Here

      return binding;
   }
  
   private boolean addBindingInMemory(Binding binding) throws Exception
   {
     Queue queue = binding.queue;
         
     if (trace) { log.trace(this + " Adding binding in memory " + binding); }
    
     lock.writeLock().acquire();
    
     try
     {   
       Integer nid = new Integer(queue.getNodeID());
      
       Map nameMap = (Map)nameMaps.get(nid);
             
       if (nameMap != null && nameMap.containsKey(queue.getName()))
       {
         return false;
       }
      
       Long cid = new Long(queue.getChannelID());
      
       if (channelIDMap.containsKey(cid))
       {
         throw new IllegalStateException("Channel id map for node " + nid + " already contains binding for queue " + cid);
       }
      
       if (nameMap == null)
       {
         nameMap = new HashMap();
        
         nameMaps.put(nid, nameMap);
        
         if (queue.getNodeID() == thisNodeID)
         {
           localNameMap = nameMap;
         }
       }
      
       nameMap.put(queue.getName(), binding);
      
       channelIDMap.put(cid, binding);
             
       Condition condition = binding.condition;    
      
       List queues = (List)mappings.get(condition);
      
       if (queues == null)
       {
         queues = new ArrayList();
        
         if (queues.contains(queue))
         {
           throw new IllegalArgumentException("Queue is already bound with condition " + condition);
         }
        
         mappings.put(condition, queues);
       }
      
       queues.add(queue)
     }
     finally
     {
       lock.writeLock().release();
     }
    
     if (trace) { log.trace(this + " Sending cluster notification"); }
    
      //Send a notification
      ClusterNotification notification = new ClusterNotification(ClusterNotification.TYPE_BIND, queue.getNodeID(), queue.getName());
     
      clusterNotifier.sendNotification(notification);
     
      return true;
   }
View Full Code Here

      }
   }

   public synchronized Queue getDefaultDLQInstance() throws Exception
   {
      Queue dlq = null;

      if (defaultDLQObjectName != null)
      {
         ManagedQueue dest = null;

         // This can be null... JMXAccessor will return null if InstanceNotFoundException is caught
         dest = (ManagedQueue) JMXAccessor.getJMXAttributeOverSecurity(getServer(), defaultDLQObjectName, "Instance");

         if (dest != null && dest.getName() != null)
         {
            Binding binding = postOffice.getBindingForQueueName(dest.getName());

            if (binding == null)
            {
              throw new IllegalStateException("Cannot find binding for queue " + dest.getName());
            }

            Queue queue = binding.queue;

            if (queue.isActive())
            {
              dlq = queue;
            }
         }
      }
View Full Code Here

      return dlq;
   }

   public synchronized Queue getDefaultExpiryQueueInstance() throws Exception
   {
      Queue expiryQueue = null;

      if (defaultExpiryQueueObjectName != null)
      {
         ManagedQueue dest = null;

         try
         {

            dest = (ManagedQueue)JMXAccessor.getJMXAttributeOverSecurity(getServer(), defaultExpiryQueueObjectName, "Instance");
         }
         catch (InstanceNotFoundException e)
         {
            //Ok
         }

         if (dest != null && dest.getName() != null)
         {
           Binding binding = postOffice.getBindingForQueueName(dest.getName());

            if (binding == null)
            {
              throw new IllegalStateException("Cannot find binding for queue " + dest.getName());
            }

            Queue queue = binding.queue;

            if (queue.isActive())
            {
              expiryQueue = queue;
            }
         }
      }
View Full Code Here

      Iterator iter = queues.iterator();

      while (iter.hasNext())
      {
         Queue queue = (Queue)iter.next();

         queue.removeAllReferences();
      }

      //undeploy the mbean
      if (!undeployDestination(isQueue, name))
      {
         return false;
      }

      //Unbind the destination's queues

      while (iter.hasNext())
      {
         Queue queue = (Queue)iter.next();

         queue.removeAllReferences();

         //Durable subs need to be removed on all nodes
         boolean all = !isQueue && queue.isRecoverable();

         postOffice.removeBinding(queue.getName(), all);
      }

      return true;
   }
View Full Code Here

                  if (selector != null)
                  {
                     filter = filterFactory.createFilter(selector);
                  }

                  Queue queue = new MessagingQueue(thisNodeID, queueName, channelID, ms, pm,
                                                   true, filter, bindingClustered && clustered);

                  if (trace) { log.trace(this + " loaded binding from storage: " + queueName); }

                  Condition condition = conditionFactory.createCondition(conditionText);
View Full Code Here

      {
        Binding binding = (Binding)iter.next();
       
        addBindingInMemory(binding);   
       
        Queue queue = binding.queue;
        
         //Need to broadcast it too
         if (clustered && queue.isClustered())
         {
           String filterString = queue.getFilter() == null ? null : queue.getFilter().getFilterString();                     
          
           MappingInfo info = new MappingInfo(thisNodeID, queue.getName(), binding.condition.toText(), filterString, queue.getChannelID(),
                                            queue.isRecoverable(), true,
                                            binding.allNodes,
                                            queue.getFullSize(), queue.getPageSize(), queue.getDownCacheSize(),
                                            queue.getMaxSize(),
                                            queue.getRecoverDeliveriesTimeout());
          
            ClusterRequest request = new BindRequest(info, binding.allNodes);

            log.trace("Multicasting bind all");
            groupMember.multicastControl(request, false);        
View Full Code Here

TOP

Related Classes of org.jboss.messaging.core.contract.Queue

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.