Package org.jboss.messaging.core.plugin.postoffice

Examples of org.jboss.messaging.core.plugin.postoffice.Binding


      while (iter.hasNext())
      {
         BindingInfo info = (BindingInfo)iter.next();
         Condition condition = conditionFactory.createCondition(info.getConditionText());
         Binding binding =
            createBinding(info.getNodeId(), condition, info.getQueueName(), info.getChannelId(),
                          info.getFilterString(), info.isDurable(), true);

         if (binding.getNodeID() == this.currentNodeId)
         {
            //We deactivate if this is one of our own bindings - it can only
            //be one of our own durable bindings - and since state is retrieved before we are fully started
            //then the sub hasn't been deployed so must be deactivated

            binding.getQueue().deactivate();
         }

         addBinding(binding);
      }
View Full Code Here


            ArrayList namesToRemove = new ArrayList();

            for (Iterator i = subMaps.entrySet().iterator(); i.hasNext();)
            {
               Map.Entry entry = (Map.Entry)i.next();
               Binding binding = (Binding )entry.getValue();

               // Sanity check
               if (!binding.getQueue().isRecoverable())
               {
                  throw new IllegalStateException("Found non recoverable queue " +
                     binding.getQueue().getName() + "in map, these should have been removed!");
               }

               // Sanity check
               if (!binding.getQueue().isClustered())
               {
                  throw new IllegalStateException("Queue " + binding.getQueue().getName() +
                     " is not clustered!");
               }

               ClusteredQueue queue = (ClusteredQueue)binding.getQueue();
              
               // Sanity check
               if (!queue.isClustered())
               {
                  //We don't fail over non clustered queues
                  log.debug("Not failing over non clustered queue " + queue.getName());
               }
               else
               {                                  
                  namesToRemove.add(entry);
               }
            }

            if (trace) { log.trace("deleting " + namesToRemove.size() + " bindings from old node"); }

            for (Iterator i = namesToRemove.iterator(); i.hasNext(); )
            {
               Map.Entry entry = (Map.Entry)i.next();
               Binding binding = (Binding)entry.getValue();
               RemoteQueueStub stub = (RemoteQueueStub)binding.getQueue();
               String queueName = (String)entry.getKey();

               // First the binding is removed from the in memory condition and name maps ...
               removeBinding(failedNodeID.intValue(), queueName);

               // ... then deleted from the database
               deleteBinding(failedNodeID.intValue(), queueName);

               log.debug(this + " deleted binding for " + queueName);

               // Note we do not need to send an unbind request across the cluster - this is because
               // when the node crashes a view change will hit the other nodes and that will cause
               // all binding data for that node to be removed anyway.
               Binding current = internalGetBindingForQueueName(queueName);

               if (current == null)
               {
                  log.debug(this + " did not have a " + queueName + " queue so no need to merge");
               }
               else
               {
                  log.debug(this + " has already a " + queueName + " queue so merging queues");
               }
              
               if (current != null)
               {
                  //need to merge the queues
                  log.debug("Merging queue " + queueName);
                 
                  LocalClusteredQueue currentQueue = (LocalClusteredQueue)current.getQueue();
                 
                  currentQueue.mergeIn(stub);
                 
                  log.debug("Merged queue");      
               }
               else
               {
                  // Create a new binding
                  Binding newBinding =
                     createBinding(currentNodeId, binding.getCondition(), stub.getName(),
                                   stub.getChannelID(), stub.getFilter(), stub.isRecoverable(),
                                   true);
  
                  // Insert it into the database
                  insertBinding(newBinding);
  
                  LocalClusteredQueue clusteredQueue = (LocalClusteredQueue)newBinding.getQueue();
  
                  clusteredQueue.deactivate();
                  clusteredQueue.load();
                  clusteredQueue.activate();
  
View Full Code Here

     
      if (trace) { log.trace("Executing PullMessagesRequest with id: " + id + " hold: " + hold); }
     
      if (hold)
      {                          
         Binding binding = office.getBindingForQueueName(queueName);
        
         if (binding == null)
         {
            throw new IllegalStateException("Cannot find binding for queue: " + queueName);
         }
        
         LocalClusteredQueue queue = (LocalClusteredQueue)binding.getQueue();
        
         queue.handleGetDeliveriesRequest(nodeId, numMessages, id, this);
         
         return null;
      }
View Full Code Here

         try
         {
            ref = messageStore.reference(msg);        

            //Need to get the post office reference lazily, cannot pass into constructor
            Binding binding = postOffice.getBindingforChannelId(channelID);
           
            if (binding == null)
            {
               throw new IllegalStateException("Cannot find binding for channel id " + channelID);
            }
           
            Queue queue = binding.getQueue();
                       
            if (trace) log.trace("Destination for message[ID=" + ref.getMessage().getMessageID() + "] is: " + queue);
  
            queue.handle(null, ref, tx);
         }
View Full Code Here

         try
         {
            ref = messageStore.reference(msg);        

            // Need to get the post office reference lazily, cannot pass into constructor
            Binding binding = postOffice.getBindingforChannelId(channelID);
           
            if (binding == null)
            {
               throw new IllegalStateException("Cannot find binding for channel id " + channelID);
            }
           
            Queue queue = binding.getQueue();
  
            if (trace) log.trace("Destination for message[ID=" + ref.getMessage().getMessageID() + "] is: " + queue);
  
            //Create a new delivery - note that it must have a delivery observer otherwise acknowledge will fail
            Delivery del = new SimpleDelivery(queue, ref);
View Full Code Here

         PagingFilteredQueue queue1 =
            new PagingFilteredQueue("durableQueue", channelIDManager.getID(), ms, pm, true, true,
                                    -1, null);
        
        
         Binding binding1 =
            office1.bindQueue(new SimpleCondition("condition1"), queue1);
        
         //Binding twice with the same name should fail     
         try
         {
            office1.bindQueue(new SimpleCondition("condition1"), queue1);
            fail();
         }
         catch (IllegalArgumentException e)
         {
            //Ok
         }
              
         //Bind one non durable
         PagingFilteredQueue queue2 =
            new PagingFilteredQueue("nonDurableQueue", channelIDManager.getID(), ms, pm, true,
                                    false, -1, null);
        
         Binding binding2 =
            office1.bindQueue(new SimpleCondition("condition2"), queue2);
        
         //Check they're there
        
         Binding binding3 = office1.getBindingForQueueName("durableQueue");
         assertNotNull(binding3);
         assertTrue(binding1 == binding3);
         assertEquivalent(binding1, binding3);
         assertTrue(binding3.getQueue().isActive());
         assertEquals(true, binding3.getQueue().isRecoverable());
        
        
         Binding binding4 = office1.getBindingForQueueName("nonDurableQueue");
         assertNotNull(binding4);
         assertTrue(binding2 == binding4);
         assertEquivalent(binding2, binding4);
         assertTrue(binding4.getQueue().isActive());
         assertEquals(false, binding4.getQueue().isRecoverable());
        
         office1.stop();
        
         //Throw away the office and create another
         office2 = createPostOffice();
        
         //Only one binding should be there
         Binding binding5 = office2.getBindingForQueueName("durableQueue");
         assertNotNull(binding5);
         assertEquivalent(binding1, binding5);
         //Should be inactive
         assertFalse(binding5.getQueue().isActive());
        
         Binding binding6 = office2.getBindingForQueueName("nonDurableQueue");
         assertNull(binding6);
        
         //Unbind the binding
         Binding binding7 = office2.unbindQueue("durableQueue");
         assertNotNull(binding7);
         assertEquivalent(binding1, binding7);
        
         //Make sure no longer there
         Binding binding8 = office2.getBindingForQueueName("durableQueue");
         assertNull(binding8);
        
         office2.stop();
        
         //Throw away office and start another
         office3 = createPostOffice();
        
         //Make sure not there
         Binding binding9 = office3.getBindingForQueueName("durableQueue");
         assertNull(binding9);
        
        
      }
      finally
View Full Code Here

      {     
         office = createPostOffice();
        
         PagingFilteredQueue queue1 = new PagingFilteredQueue("queue1", channelIDManager.getID(), ms, pm, true, false, -1, null);
        
         Binding binding1 =
            office.bindQueue(new SimpleCondition("condition1"), queue1);
        
         PagingFilteredQueue queue2 = new PagingFilteredQueue("queue2", channelIDManager.getID(), ms, pm, true, false, -1, null);
        
         Binding binding2 =
            office.bindQueue(new SimpleCondition("condition1"), queue2);
        
         PagingFilteredQueue queue3 = new PagingFilteredQueue("queue3", channelIDManager.getID(), ms, pm, true, false, -1, null);
        
         Binding binding3 =
            office.bindQueue(new SimpleCondition("condition1"), queue3);
        
         PagingFilteredQueue queue4 = new PagingFilteredQueue("queue4", channelIDManager.getID(), ms, pm, true, false, -1, null);
        
         Binding binding4 =
            office.bindQueue(new SimpleCondition("condition1"), queue4);
        
         PagingFilteredQueue queue5 = new PagingFilteredQueue("queue5", channelIDManager.getID(), ms, pm, true, false, -1, null);
        
         Binding binding5 =
            office.bindQueue(new SimpleCondition("condition2"), queue5);
        
         PagingFilteredQueue queue6 = new PagingFilteredQueue("queue6", channelIDManager.getID(), ms, pm, true, false, -1, null);
        
         Binding binding6 =
            office.bindQueue(new SimpleCondition("condition2"), queue6);
        
         PagingFilteredQueue queue7 = new PagingFilteredQueue("queue7", channelIDManager.getID(), ms, pm, true, false, -1, null);
        
         Binding binding7 =
            office.bindQueue(new SimpleCondition("condition2"), queue7);
        
         PagingFilteredQueue queue8 = new PagingFilteredQueue("queue8", channelIDManager.getID(), ms, pm, true, false, -1, null);
        
         Binding binding8 =
            office.bindQueue(new SimpleCondition("condition2"), queue8);
        
        
         Collection bindings = office.getBindingsForCondition(new SimpleCondition("dummy"));
         assertNotNull(bindings);
View Full Code Here

        
         LocalClusteredQueue queue1 =
            new LocalClusteredQueue(office1, 1, "sub1", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);

         Binding binding1 =
            office1.bindClusteredQueue(new SimpleCondition("topic1"), queue1);
        
         log.info("Added binding1");
        
         LocalClusteredQueue queue2 =
            new LocalClusteredQueue(office1, 1, "sub2", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);

         Binding binding2 =
            office1.bindClusteredQueue(new SimpleCondition("topic1"), queue2);
        
         log.info("Added binding2");
        
         // Start another office - make sure it picks up the bindings from the first node
        
         office2 = createClusteredPostOffice(2, "testgroup", sc, ms, pm, tr);
        
         log.info("Created office 2");
        
         Collection bindings = office2.listAllBindingsForCondition(new SimpleCondition("topic1"));
         assertNotNull(bindings);
         assertEquals(2, bindings.size());
        
         Iterator iter = bindings.iterator();
         assertEquivalent(binding1, (Binding)iter.next());
         assertEquivalent(binding2, (Binding)iter.next());        
        
         // Add another binding on node 2
        
         LocalClusteredQueue queue3 =
            new LocalClusteredQueue(office2, 2, "sub3", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);

         Binding binding3 =
            office2.bindClusteredQueue(new SimpleCondition("topic1"), queue3);
 
         // Make sure both nodes pick it up
        
         bindings = office1.listAllBindingsForCondition(new SimpleCondition("topic1"));
         assertNotNull(bindings);
         assertEquals(3, bindings.size());
        
         iter = bindings.iterator();
         assertEquivalent(binding1, (Binding)iter.next());
         assertEquivalent(binding2, (Binding)iter.next());
         assertEquivalent(binding3, (Binding)iter.next());

         bindings = office2.listAllBindingsForCondition(new SimpleCondition("topic1"));
         assertNotNull(bindings);
         assertEquals(3, bindings.size());
        
         iter = bindings.iterator();
         assertEquivalent(binding1, (Binding)iter.next());
         assertEquivalent(binding2, (Binding)iter.next());
         assertEquivalent(binding3, (Binding)iter.next());

         // Add another binding on node 1
        
         LocalClusteredQueue queue4 =
            new LocalClusteredQueue(office2, 2, "sub4", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);

         Binding binding4 =
            office2.bindClusteredQueue(new SimpleCondition("topic1"), queue4);
        
         // Make sure both nodes pick it up
        
         bindings = office1.listAllBindingsForCondition(new SimpleCondition("topic1"));
         assertNotNull(bindings);
         assertEquals(4, bindings.size());
        
         iter = bindings.iterator();
         assertEquivalent(binding1, (Binding)iter.next());
         assertEquivalent(binding2, (Binding)iter.next());
         assertEquivalent(binding3, (Binding)iter.next());
         assertEquivalent(binding4, (Binding)iter.next());
        
         bindings = office2.listAllBindingsForCondition(new SimpleCondition("topic1"));
         assertNotNull(bindings);
         assertEquals(4, bindings.size());
        
         iter = bindings.iterator();
         assertEquivalent(binding1, (Binding)iter.next());
         assertEquivalent(binding2, (Binding)iter.next());
         assertEquivalent(binding3, (Binding)iter.next());
         assertEquivalent(binding4, (Binding)iter.next());
        
         // Unbind binding 1 and binding 2
         office1.unbindClusteredQueue("sub1");
         office1.unbindClusteredQueue("sub2");
        
         // Make sure bindings are not longer available on either node
        
         bindings = office1.listAllBindingsForCondition(new SimpleCondition("topic1"));
         assertNotNull(bindings);
         assertEquals(2, bindings.size());
        
         iter = bindings.iterator();
         assertEquivalent(binding3, (Binding)iter.next());
         assertEquivalent(binding4, (Binding)iter.next());
  
         bindings = office2.listAllBindingsForCondition(new SimpleCondition("topic1"));
         assertNotNull(bindings);
         assertEquals(2, bindings.size());
        
         iter = bindings.iterator();
         assertEquivalent(binding3, (Binding)iter.next());
         assertEquivalent(binding4, (Binding)iter.next());

         // Add a third office
                 
         office3 = createClusteredPostOffice(3, "testgroup", sc, ms, pm, tr);
        
         // Maks sure it picks up the bindings
        
         bindings = office3.listAllBindingsForCondition(new SimpleCondition("topic1"));
         assertNotNull(bindings);
         assertEquals(2, bindings.size());
        
         iter = bindings.iterator();
         assertEquivalent(binding3, (Binding)iter.next());
         assertEquivalent(binding4, (Binding)iter.next());
        
         // Add another binding on node 3
                 
         LocalClusteredQueue queue5 =
            new LocalClusteredQueue(office3, 3, "sub5", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);
        
         Binding binding5 =
            office3.bindClusteredQueue(new SimpleCondition("topic1"), queue5);
        
         // Make sure all nodes pick it up
        
         bindings = office1.listAllBindingsForCondition(new SimpleCondition("topic1"));
         assertNotNull(bindings);
         assertEquals(3, bindings.size());
        
         iter = bindings.iterator();
         assertEquivalent(binding3, (Binding)iter.next());
         assertEquivalent(binding4, (Binding)iter.next());
         assertEquivalent(binding5, (Binding)iter.next());
        
         bindings = office2.listAllBindingsForCondition(new SimpleCondition("topic1"));
         assertNotNull(bindings);
         assertEquals(3, bindings.size());
        
         iter = bindings.iterator();
         assertEquivalent(binding3, (Binding)iter.next());
         assertEquivalent(binding4, (Binding)iter.next());
         assertEquivalent(binding5, (Binding)iter.next());
        
         bindings = office3.listAllBindingsForCondition(new SimpleCondition("topic1"));
         assertNotNull(bindings);
         assertEquals(3, bindings.size());
        
         iter = bindings.iterator();
         assertEquivalent(binding3, (Binding)iter.next());
         assertEquivalent(binding4, (Binding)iter.next());
         assertEquivalent(binding5, (Binding)iter.next());
        
         // Add a durable and a non durable binding on node 1
        
         LocalClusteredQueue queue6 =
            new LocalClusteredQueue(office1, 1, "sub6", channelIDManager.getID(), ms, pm,
                                    true, true, -1, null, tr);
        
         Binding binding6 =
            office1.bindClusteredQueue(new SimpleCondition("topic1"), queue6);
        
         LocalClusteredQueue queue7 =
            new LocalClusteredQueue(office1, 1, "sub7", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);
        
         Binding binding7 =
            office1.bindClusteredQueue(new SimpleCondition("topic1"), queue7);
        
         // Make sure all nodes pick them up
        
         bindings = office1.listAllBindingsForCondition(new SimpleCondition("topic1"));
View Full Code Here

TOP

Related Classes of org.jboss.messaging.core.plugin.postoffice.Binding

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.