Examples of PostOffice


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

      // If this is a consumer of a non durable subscription then we want to unbind the
      // subscription and delete all its data.

      if (destination.isTopic())
      {
         PostOffice postOffice = sessionEndpoint.getConnectionEndpoint().getServerPeer().getPostOfficeInstance();
                 
         ServerPeer sp = sessionEndpoint.getConnectionEndpoint().getServerPeer();
        
         Queue queue = postOffice.getBindingForQueueName(queueName).queue;       
        
         ManagedDestination mDest = sp.getDestinationManager().getDestination(destination.getName(), false);
        
         if (!queue.isRecoverable())
         {
            postOffice.removeBinding(queueName, false);           

            if (!mDest.isTemporary())
            {
              String counterName = TopicService.SUBSCRIPTION_MESSAGECOUNTER_PREFIX + queueName;
 
              MessageCounter counter = sp.getMessageCounterManager().unregisterMessageCounter(counterName);
 
              if (counter == null)
              {
                 throw new IllegalStateException("Cannot find counter to remove " + counterName);
              }
            }
         }
         else
         {
           //Durable sub consumer
          
           if (queue.isClustered() && postOffice.isClustered())
            {
              //Clustered durable sub consumer created - we need to remove this info from the replicator
             
              Replicator rep = (Replicator)postOffice;
             
View Full Code Here

Examples of org.jboss.messaging.core.plugin.contract.PostOffice

      // If this is a consumer of a non durable subscription then we want to unbind the
      // subscription and delete all its data.

      if (destination.isTopic())
      {
         PostOffice postOffice = sessionEndpoint.getConnectionEndpoint()
                  .getServerPeer().getPostOfficeInstance();

         Binding binding = postOffice.getBindingForQueueName(queueName);

         // Note binding can be null since there can many competing subscribers for the
         // subscription - in which case the first will have removed the subscription and
         // subsequently ones won't find it

         if (binding != null && !binding.getQueue().isRecoverable())
         {
            Queue queue = binding.getQueue();
            if (!queue.isClustered())
            {
               postOffice.unbindQueue(queue.getName());
            }
            else
            {
               ((ClusteredPostOffice)postOffice).unbindClusteredQueue(queue.getName());
            }
View Full Code Here

Examples of org.jboss.messaging.core.plugin.contract.PostOffice

  
   public void setMaxSize(int maxSize) throws Exception
   {
      Condition cond = new JMSCondition(isQueue(), name);
     
      PostOffice postOffice = serverPeer.getPostOfficeInstance();
     
      Collection subs = postOffice.getBindingsForCondition(cond);
     
      Iterator iter = subs.iterator();

      while (iter.hasNext())
      {
View Full Code Here

Examples of org.jboss.messaging.core.plugin.contract.PostOffice

            //Ok
         }
        
         if (dest != null)
         {           
            PostOffice po = getPostOfficeInstance();
           
            Binding binding = po.getBindingForQueueName(dest.getName());
           
            if (binding != null && binding.getQueue().isActive())
            {
               dlq =  binding.getQueue();
            }
View Full Code Here

Examples of org.jboss.messaging.core.plugin.contract.PostOffice

            //Ok
         }

         if (dest != null)
         {           
            PostOffice po = getPostOfficeInstance();
           
            Binding binding = po.getBindingForQueueName(dest.getName());
           
            if (binding != null && binding.getQueue().isActive())
            {
               expiryQueue =  binding.getQueue();
            }
View Full Code Here

Examples of org.jboss.messaging.core.plugin.contract.PostOffice

      return postOffice;
   }

   public Replicator getReplicator() throws Exception
   {
      PostOffice postOffice = getPostOfficeInstance();
      if (!(postOffice instanceof Replicator))
      {
         throw new  IllegalAccessException("This operations is only legal on clustering configurations");
      }
      return (Replicator)postOffice;
View Full Code Here

Examples of org.jboss.messaging.core.plugin.contract.PostOffice

   // Public --------------------------------------------------------

   public final void testBind() throws Throwable
   {
      PostOffice office1 = null;
     
      PostOffice office2 = null;
     
      PostOffice office3 = null;
     
      try
      {            
         office1 = createPostOffice();
        
         //Bind one durable
        
         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

Examples of org.jboss.messaging.core.plugin.contract.PostOffice

           
   }
  
   public final void testListBindings() throws Throwable
   {
      PostOffice office = null;
     
      try
      {     
         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);
         assertTrue(bindings.isEmpty());
        
         //We don't match on substrings
         bindings = office.getBindingsForCondition(new SimpleCondition("condition123"));
         assertNotNull(bindings);
         assertTrue(bindings.isEmpty());
        
         //We don't currently support hierarchies
         bindings = office.getBindingsForCondition(new SimpleCondition("condition1.subcondition"));
         assertNotNull(bindings);
         assertTrue(bindings.isEmpty());
        
         //We currently just do an exact match
         bindings = office.getBindingsForCondition(new SimpleCondition("condition1"));
         assertNotNull(bindings);
         assertEquals(4, bindings.size());
        
         Iterator iter = bindings.iterator();
         assertEquivalent((Binding)iter.next(), binding1);
         assertEquivalent((Binding)iter.next(), binding2);
         assertEquivalent((Binding)iter.next(), binding3);
         assertEquivalent((Binding)iter.next(), binding4);
        
         bindings = office.getBindingsForCondition(new SimpleCondition("condition2"));
         assertNotNull(bindings);
         assertEquals(4, bindings.size());
        
         iter = bindings.iterator();
         assertEquivalent((Binding)iter.next(), binding5);
         assertEquivalent((Binding)iter.next(), binding6);
         assertEquivalent((Binding)iter.next(), binding7);
         assertEquivalent((Binding)iter.next(), binding8);
      }
      finally
      {
         if (office != null)
         {
            office.stop();
         }
      }
        
   }
View Full Code Here

Examples of org.jboss.messaging.core.plugin.contract.PostOffice

   }
  
     
   public final void testRouteInactive() throws Throwable
   {
      PostOffice postOffice = null;
     
      try
      {
     
         postOffice = createPostOffice();
        
         PagingFilteredQueue queue1 =
            new PagingFilteredQueue("queue1", channelIDManager.getID(), ms, pm, true, false,
                                    -1, null);
        
         postOffice.bindQueue(new SimpleCondition("topic1"), queue1);
        
         PagingFilteredQueue queue2 =
            new PagingFilteredQueue("queue2", channelIDManager.getID(), ms, pm, true, false,
                                    -1, null);
        
         postOffice.bindQueue(new SimpleCondition("topic1"), queue2);
        
         PagingFilteredQueue queue3 =
            new PagingFilteredQueue("queue3", channelIDManager.getID(), ms, pm, true, false,
                                    -1, null);
        
         postOffice.bindQueue(new SimpleCondition("topic1"), queue3);
        
         PagingFilteredQueue queue4 =
            new PagingFilteredQueue("queue4", channelIDManager.getID(), ms, pm, true, false,
                                    -1, null);
        
         postOffice.bindQueue(new SimpleCondition("topic2"), queue4);
        
         PagingFilteredQueue queue5 =
            new PagingFilteredQueue("queue5", channelIDManager.getID(), ms, pm, true, false,
                                    -1, null);
        
         postOffice.bindQueue(new SimpleCondition("topic2"), queue5);
        
         PagingFilteredQueue queue6 =
            new PagingFilteredQueue("queue6", channelIDManager.getID(), ms, pm, true, false,
                                    -1, null);
        
         postOffice.bindQueue(new SimpleCondition("topic2"), queue6);
     
         SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         queue1.add(receiver1);
         SimpleReceiver receiver2 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         queue2.add(receiver2);
         SimpleReceiver receiver3 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         queue3.add(receiver3);
         SimpleReceiver receiver4 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         queue4.add(receiver4);
         SimpleReceiver receiver5 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         queue5.add(receiver5);
         SimpleReceiver receiver6 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         queue6.add(receiver6);
        
         queue1.deactivate();
         queue2.deactivate();
         queue5.deactivate();
         queue6.deactivate();
        
         assertFalse(queue1.isActive());     
         assertFalse(queue2.isActive());
         assertFalse(queue5.isActive());
         assertFalse(queue6.isActive());
         assertTrue(queue3.isActive());
         assertTrue(queue4.isActive());     
        
         Message msg1 = CoreMessageFactory.createCoreMessage(1);     
         MessageReference ref1 = ms.reference(msg1);
        
         boolean routed = postOffice.route(ref1, new SimpleCondition("topic1"), null);     
         assertTrue(routed);
        
         List msgs = receiver1.getMessages();
         assertNotNull(msgs);
         assertTrue(msgs.isEmpty());
        
         msgs = receiver2.getMessages();
         assertNotNull(msgs);
         assertTrue(msgs.isEmpty());
        
         msgs = receiver3.getMessages();
         assertNotNull(msgs);
         assertEquals(1, msgs.size());
         Message msgRec = (Message)msgs.get(0);
         assertTrue(msg1 == msgRec);
         receiver3.acknowledge(msgRec, null);
         msgs = queue3.browse();
         assertNotNull(msgs);
         assertTrue(msgs.isEmpty())
        
         msgs = receiver4.getMessages();
         assertNotNull(msgs);
         assertTrue(msgs.isEmpty());
        
         msgs = receiver5.getMessages();
         assertNotNull(msgs);
         assertTrue(msgs.isEmpty());
        
         msgs = receiver6.getMessages();
         assertNotNull(msgs);
         assertTrue(msgs.isEmpty());
        
         receiver3.clear();
                    
         Message msg2 = CoreMessageFactory.createCoreMessage(2);     
         MessageReference ref2 = ms.reference(msg2);
        
         routed = postOffice.route(ref2, new SimpleCondition("topic2"), null);     
         assertTrue(routed);
        
         msgs = receiver1.getMessages();
         assertNotNull(msgs);
         assertTrue(msgs.isEmpty());
        
         msgs = receiver2.getMessages();
         assertNotNull(msgs);
         assertTrue(msgs.isEmpty());
        
         msgs = receiver3.getMessages();
         assertNotNull(msgs);
         assertTrue(msgs.isEmpty());     
        
         msgs = receiver4.getMessages();
         assertNotNull(msgs);
         assertEquals(1, msgs.size());
         msgRec = (Message)msgs.get(0);
         assertTrue(msg2 == msgRec);
         receiver4.acknowledge(msgRec, null);
         msgs = queue4.browse();
         assertNotNull(msgs);
         assertTrue(msgs.isEmpty())
        
         msgs = receiver5.getMessages();
         assertNotNull(msgs);
         assertTrue(msgs.isEmpty());
        
         msgs = receiver6.getMessages();
         assertNotNull(msgs);
         assertTrue(msgs.isEmpty());
        
         if (checkNoMessageData())
         {
            fail("data still in database");
         }
      }
      finally
      {
         if (postOffice != null)
         {
            postOffice.stop();
         }
        
      }
  
   }
View Full Code Here

Examples of org.jboss.messaging.core.plugin.contract.PostOffice

  
   }

   public final void testRouteNoBinding() throws Throwable
   {
      PostOffice postOffice = null;
     
      try
      {     
         postOffice = createPostOffice();
        
         PagingFilteredQueue queue1 =
            new PagingFilteredQueue("queue1", channelIDManager.getID(), ms, pm, true, false,
                                    -1, null);
        
         postOffice.bindQueue(new SimpleCondition("condition1"), queue1);
             
         SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);;
         queue1.add(receiver1);
  
         assertTrue(queue1.isActive());
  
         Message msg1 = CoreMessageFactory.createCoreMessage(1);     
         MessageReference ref1 = ms.reference(msg1);
        
         boolean routed =
            postOffice.route(ref1, new SimpleCondition("this won't match anything"), null);
        
         assertFalse(routed);
              
         List msgs = receiver1.getMessages();
         assertNotNull(msgs);
         assertTrue(msgs.isEmpty())
        
         if (checkNoMessageData())
         {
            fail("data still in database");
         }
        
      }
      finally
      {
         if (postOffice != null)
         {
            postOffice.stop();
         }
        
      }
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.