Package org.jboss.messaging.core.contract

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


         Iterator iter = queues.iterator();

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

           if (!localOnly || (queue.getNodeID() == thisNodeID))
           {
             list.add(queue);
           }
         }
View Full Code Here


         if (mapping.getFilterString() != null)
         {
           filter = filterFactory.createFilter(mapping.getFilterString());
         }
        
         Queue queue = new MessagingQueue(mapping.getNodeId(), mapping.getQueueName(), mapping.getChannelId(),
                                          mapping.isRecoverable(), filter, true);
        
         Condition condition = conditionFactory.createCondition(mapping.getConditionText());
        
         addBindingInMemory(new Binding(condition, queue, false));
        
         if (mapping.isAllNodes())
         {
           // insert into db if not already there
           if (!loadedBindings.containsKey(queue.getName()))
           {
             //Create a local binding too
            
            long channelID = channelIDManager.getID();
                       
            Queue queue2 = new MessagingQueue(thisNodeID, mapping.getQueueName(), channelID, ms, pm,
                                             mapping.isRecoverable(), mapping.getMaxSize(), filter,
                                             mapping.getFullSize(), mapping.getPageSize(), mapping.getDownCacheSize(),
                                             true, mapping.getRecoverDeliveriesTimeout());    
           
            Binding localBinding = new Binding(condition, queue2, true);
View Full Code Here

         
          while (iter2.hasNext())
          {
            Binding binding = (Binding)iter2.next();
         
            Queue queue = binding.queue;
           
            //We only get the clustered queues
            if (queue.isClustered())
            {             
              String filterString = queue.getFilter() == null ? null : queue.getFilter().getFilterString();
             
              MappingInfo mapping;
             
              if (binding.allNodes)
              {
                mapping = new MappingInfo(queue.getNodeID(), queue.getName(), binding.condition.toText(), filterString,
                                           queue.getChannelID(), queue.isRecoverable(), true, true,
                                    queue.getFullSize(), queue.getPageSize(), queue.getDownCacheSize(),
                                    queue.getMaxSize(), queue.getRecoverDeliveriesTimeout());
              }
              else
              {
                mapping = new MappingInfo(queue.getNodeID(), queue.getName(), binding.condition.toText(),
                                        filterString, queue.getChannelID(), queue.isRecoverable(),
                                        true, false);    
              }
              list.add(mapping);
            }
          }
View Full Code Here

      if (mapping.getFilterString() != null)
      {
        filter = filterFactory.createFilter(mapping.getFilterString());
      }
     
      Queue queue = new MessagingQueue(mapping.getNodeId(), mapping.getQueueName(), mapping.getChannelId(),
                                       mapping.isRecoverable(), filter, mapping.isClustered());
     
      Condition condition = conditionFactory.createCondition(mapping.getConditionText());
     
      //addBindingInMemory(new Binding(condition, queue, mapping.isAllNodes()));
      addBindingInMemory(new Binding(condition, queue, false));
     
      if (allNodes)
     {
       if (trace) { log.trace("allNodes is true, so also forcing a local bind"); }
      
       //There is the possibility that two nodes send a bind all with the same name simultaneously OR
       //a node starts and sends a bind "ALL" and the other nodes already have a queue with that name
       //This is ok - but we must check for this and not create the local binding in this case
                            
       //Bind locally

       long channelID = channelIDManager.getID();
      
       Queue queue2 = new MessagingQueue(thisNodeID, mapping.getQueueName(), channelID, ms, pm,
                                        mapping.isRecoverable(), mapping.getMaxSize(), filter,
                                        mapping.getFullSize(), mapping.getPageSize(), mapping.getDownCacheSize(), true,
                                        mapping.getRecoverDeliveriesTimeout());

       //We must cast back asynchronously to avoid deadlock
       //we need put adding binding and queue's loading and activations into one sync block
       //https://jira.jboss.org/jira/browse/JBMESSAGING-1760
         synchronized (queue2)
         {
            boolean added = internalAddBinding(new Binding(condition, queue2, true), false, false);

            if (added)
            {
               if (trace)
               {
                  log.trace(this + " inserted in binding locally");
               }
               queue2.load();

               queue2.activate();
            }
         }
     }
     
      synchronized (waitForBindUnbindLock)
View Full Code Here

       //will request for deliveries to be sent to it in a batch
       //We still send back a response though to prevent the sender blocking waiting for a reply
     }
     else
     {    
       Queue queue = binding.queue;
      
       queue.addToRecoveryArea(nodeID, messageID, sessionID);    
     }
    
     if (trace) { log.trace(this + " reply address is " + replyAddress); }
    
     if (replyAddress != null)
View Full Code Here

     {
       //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); }
    
      boolean intr = Thread.interrupted();
      for (;;)
      {
         try
         {
            lock.writeLock().acquire();
            break;
         }
         catch (InterruptedException ex)
         {
            intr = true;
         }
      }
    
     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 (intr) Thread.currentThread().interrupt();
     }
    
     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

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.