Package org.jboss.messaging.core.contract

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


      return postOffice.nodeIDView();
   }

   public Map getFailoverMap() throws Exception
   {
      PostOffice postOffice = (PostOffice)sc.getAttribute(postOfficeObjectName, "Instance");

      return postOffice.getFailoverMap();
   }
View Full Code Here


      return postOffice.getFailoverMap();
   }

   public Map getRecoveryArea(String queueName) throws Exception
   {
      PostOffice postOffice = (PostOffice)sc.getAttribute(postOfficeObjectName, "Instance");

      return postOffice.getRecoveryArea(queueName);
   }
View Full Code Here

      return postOffice.getRecoveryArea(queueName);
   }

   public int getRecoveryMapSize(String queueName) throws Exception
   {
      PostOffice postOffice = (PostOffice)sc.getAttribute(postOfficeObjectName, "Instance");

      return postOffice.getRecoveryMapSize(queueName);
   }
View Full Code Here

      * e) close down all nodes
      * f) start all nodes
      * g) verify queue is not known
      * */
    
      PostOffice office1 = null;
      PostOffice office2 = null;
      PostOffice office3 = null;
     
      try
      {                         
         office1 = createClusteredPostOffice(1);
         office2 = createClusteredPostOffice(2);
         office3 = createClusteredPostOffice(3);        
                            
         //Durable
         Queue queue1 = new MessagingQueue(1, "sub1", channelIDManager.getID(), ms, pm, true, -1, null, true);
         queue1.activate();

         Condition condition1 = new SimpleCondition("condition1");
        
         //Add all binding
         boolean added = office1.addBinding(new Binding(condition1, queue1, true), true);
         assertTrue(added);
        
         Thread.sleep(3000);
         
         Collection bindings = office1.getAllBindings();        
         assertGotAll(1, bindings, queue1.getName());
        
         bindings = office2.getAllBindings();        
         assertGotAll(2, bindings, queue1.getName());
        
         bindings = office3.getAllBindings();        
         assertGotAll(3, bindings, queue1.getName());
        
         //Now unbind same node
        
         Binding removed = office1.removeBinding(queue1.getName(), true);
         assertNotNull(removed);
        
         Thread.sleep(3000);
        
         bindings = office1.getAllBindings();        
         assertTrue(bindings.isEmpty());
        
         bindings = office2.getAllBindings();        
         assertTrue(bindings.isEmpty());
        
         bindings = office3.getAllBindings();        
         assertTrue(bindings.isEmpty());
        
         //Bind again different node
         Queue queue2 = new MessagingQueue(2, "sub2", channelIDManager.getID(), ms, pm, true, -1, null, true);
         queue2.activate();
        
         added = office2.addBinding(new Binding(condition1, queue2, true), true);
         assertTrue(added);
        
         Thread.sleep(3000);
        
         bindings = office1.getAllBindings();        
         assertGotAll(1, bindings, queue2.getName());
        
         bindings = office2.getAllBindings();        
         assertGotAll(2, bindings, queue2.getName());
        
         bindings = office3.getAllBindings();        
         assertGotAll(3, bindings, queue2.getName());
        
         //Close down all nodes
        
         office1.stop();
        
         dumpNodeIDView(office2);
        
         office2.stop();
        
         dumpNodeIDView(office3);
        
         office3.stop();       
        
         //Start all nodes
        
         office1.start();
         office2.start();
         office3.start();
        
         Thread.sleep(3000);
        
         //Verify the binding is there
        
         bindings = office1.getAllBindings();        
         assertGotAll(1, bindings, queue2.getName());
        
         bindings = office2.getAllBindings();        
         assertGotAll(2, bindings, queue2.getName());
        
         bindings = office3.getAllBindings();        
         assertGotAll(3, bindings, queue2.getName());
        
         //Unbind different node
        
         removed = office3.removeBinding(queue2.getName(), true);
         assertNotNull(removed);
        
         Thread.sleep(3000);
        
         bindings = office1.getAllBindings();        
         assertTrue(bindings.isEmpty());
        
         bindings = office2.getAllBindings();        
         assertTrue(bindings.isEmpty());
        
         bindings = office3.getAllBindings();        
         assertTrue(bindings.isEmpty());                                       
      }
      finally
      {
        if (office1 != null)
        {
          try
          {
            office1.stop();
          }
          catch (Exception ignore)
          {            
          }
        }

        if (office2 != null)
        {
          try
          {
            office2.stop();
          }
          catch (Exception ignore)
          {            
          }
        }

        if (office3 != null)
        {
          try
          {
            office3.stop();
          }        
          catch (Exception ignore)
          {            
          }
        }
View Full Code Here

      * a) queue is known by cluster
      * b) bind all
      * c) verify nothing changes on cluster
      */
    
      PostOffice office1 = null;
      PostOffice office2 = null;
      PostOffice office3 = null;
     
      try
      {                         
         office1 = createClusteredPostOffice(1);
         office2 = createClusteredPostOffice(2);
         office3 = createClusteredPostOffice(3);        
                          
         //Durable
         Queue queue1 = new MessagingQueue(1, "sub1", channelIDManager.getID(), ms, pm, true, -1, null, true);
         queue1.activate();

         Condition condition1 = new SimpleCondition("condition1");
        
         //Add all binding
         boolean added = office1.addBinding(new Binding(condition1, queue1, true), true);
         assertTrue(added);
        
         Thread.sleep(3000);
         
         Collection bindings = office1.getAllBindings();        
         assertGotAll(1, bindings, queue1.getName());
        
         bindings = office2.getAllBindings();        
         assertGotAll(2, bindings, queue1.getName());
        
         bindings = office3.getAllBindings();        
         assertGotAll(3, bindings, queue1.getName());
        
         //Bind again
         added = office1.addBinding(new Binding(condition1, queue1, true), true);
         assertFalse(added);
        
         Thread.sleep(3000);
         
         bindings = office1.getAllBindings();        
         assertGotAll(1, bindings, queue1.getName());
        
         bindings = office2.getAllBindings();        
         assertGotAll(2, bindings, queue1.getName());
        
         bindings = office3.getAllBindings();        
         assertGotAll(3, bindings, queue1.getName());
                 
         //Now unbind same node
        
         Binding removed = office1.removeBinding(queue1.getName(), true);
         assertNotNull(removed);
        
         removed = office1.removeBinding(queue1.getName(), true);
         assertNull(removed);
        
         Thread.sleep(3000);
        
         bindings = office1.getAllBindings();        
         assertTrue(bindings.isEmpty());
        
         bindings = office2.getAllBindings();        
         assertTrue(bindings.isEmpty());
        
         bindings = office3.getAllBindings();        
         assertTrue(bindings.isEmpty());                                             
      }
      finally
      {
        if (office1 != null)
        {
          try
          {
            office1.stop();
          }
          catch (Exception ignore)
          {            
          }
        }

        if (office2 != null)
        {
          try
          {
            office2.stop();
          }
          catch (Exception ignore)
          {            
          }
        }

        if (office3 != null)
        {
          try
          {
            office3.stop();
          }        
          catch (Exception ignore)
          {            
          }
        }
View Full Code Here

      * c) bind all
      * d) start other nodes
      * d) verify other nodes pick it up
      */
    
      PostOffice office1 = null;
      PostOffice office2 = null;
      PostOffice office3 = null;
     
      try
      {                         
         office1 = createClusteredPostOffice(1);      
                             
         //Durable
         Queue queue1 = new MessagingQueue(1, "sub1", channelIDManager.getID(), ms, pm, true, -1, null, true);
         queue1.activate();

         Condition condition1 = new SimpleCondition("condition1");
        
         //Add all binding
         boolean added = office1.addBinding(new Binding(condition1, queue1, true), true);
         assertTrue(added);
        
         Thread.sleep(3000);
         
         office2 = createClusteredPostOffice(2);      
         office3 = createClusteredPostOffice(3);      
                 
         Thread.sleep(3000);
        
         Collection bindings = office1.getAllBindings();        
         assertGotAll(1, bindings, queue1.getName());
        
         bindings = office2.getAllBindings();        
         assertGotAll(2, bindings, queue1.getName());
        
         bindings = office3.getAllBindings();        
         assertGotAll(3, bindings, queue1.getName());
              
         //Unbind
        
         Binding removed = office1.removeBinding(queue1.getName(), true);
         assertNotNull(removed);
        
         Thread.sleep(3000);
        
         bindings = office1.getAllBindings();        
         assertTrue(bindings.isEmpty());
        
         bindings = office2.getAllBindings();        
         assertTrue(bindings.isEmpty());
        
         bindings = office3.getAllBindings();        
         assertTrue(bindings.isEmpty());                                   
      }
      finally
      {
        if (office1 != null)
        {
          try
          {
            office1.stop();
          }
          catch (Exception ignore)
          {            
          }
        }

        if (office2 != null)
        {
          try
          {
            office2.stop();
          }
          catch (Exception ignore)
          {            
          }
        }

        if (office3 != null)
        {
          try
          {
            office3.stop();
          }        
          catch (Exception ignore)
          {            
          }
        }
View Full Code Here

      * d) shutdown all nodes
      * e) startup all nodes
      * f) verify queue is on all nodes
      */
    
      PostOffice office1 = null;
      PostOffice office2 = null;
      PostOffice office3 = null;
     
      try
      {                         
         office1 = createClusteredPostOffice(1);      
                          
         //Durable
         Queue queue1 = new MessagingQueue(1, "sub1", channelIDManager.getID(), ms, pm, true, -1, null, true);
         queue1.activate();

         Condition condition1 = new SimpleCondition("condition1");
        
         //Add all binding
         boolean added = office1.addBinding(new Binding(condition1, queue1, true), true);
         assertTrue(added);
        
         Thread.sleep(3000);
        
         office1.stop();
        
         //office1 = createClusteredPostOffice(1, "testgroup");
         office1.start();
         office2 = createClusteredPostOffice(2);
         office3 = createClusteredPostOffice(3);
         
         Thread.sleep(3000);
        
         Collection bindings = office1.getAllBindings();        
         assertGotAll(1, bindings, queue1.getName());
        
         bindings = office2.getAllBindings();        
         assertGotAll(2, bindings, queue1.getName());
        
         bindings = office3.getAllBindings();        
         assertGotAll(3, bindings, queue1.getName());
        
         //Now unbind same node
        
         Binding removed = office1.removeBinding(queue1.getName(), true);
         assertNotNull(removed);
        
         Thread.sleep(3000);
        
         bindings = office1.getAllBindings();        
         assertTrue(bindings.isEmpty());
        
         bindings = office2.getAllBindings();        
         assertTrue(bindings.isEmpty());
        
         bindings = office3.getAllBindings();        
         assertTrue(bindings.isEmpty());                 
      }
      finally
      {
        if (office1 != null)
        {
          try
          {
            office1.stop();
          }
          catch (Exception ignore)
          {            
          }
        }

        if (office2 != null)
        {
          try
          {
            office2.stop();
          }
          catch (Exception ignore)
          {            
          }
        }

        if (office3 != null)
        {
          try
          {
            office3.stop();
          }        
          catch (Exception ignore)
          {            
          }
        }
View Full Code Here

    * e) start other nodes
    * f) verify queue is not known
    * g) restart first node, verify queue is now known
      * */
    
      PostOffice office1 = null;
      PostOffice office2 = null;
      PostOffice office3 = null;
     
      try
      {                         
         office1 = createClusteredPostOffice(1);
                                  
         //Durable
         Queue queue1 = new MessagingQueue(1, "sub1", channelIDManager.getID(), ms, pm, true, -1, null, true);
         queue1.activate();

         Condition condition1 = new SimpleCondition("condition1");
        
         //Add all binding
         boolean added = office1.addBinding(new Binding(condition1, queue1, true), true);
         assertTrue(added);
        
         Thread.sleep(3000);
        
         office1.stop();
        
         office2 = createClusteredPostOffice(2);
         office3 = createClusteredPostOffice(3);
        
         Collection bindings = office2.getAllBindings();        
         assertTrue(bindings.isEmpty());
        
         bindings = office3.getAllBindings();        
         assertTrue(bindings.isEmpty());
            
         office1.start();
        
         Thread.sleep(3000);
           
         bindings = office1.getAllBindings();        
         assertGotAll(1, bindings, queue1.getName());
        
         bindings = office2.getAllBindings();        
         assertGotAll(2, bindings, queue1.getName());
        
         bindings = office3.getAllBindings();        
         assertGotAll(3, bindings, queue1.getName());
        
         //Now unbind same node                 
        
         Binding removed = office1.removeBinding(queue1.getName(), true);
         assertNotNull(removed);

         Thread.sleep(3000);
        
         bindings = office1.getAllBindings();        
         assertTrue(bindings.isEmpty());
        
         bindings = office2.getAllBindings();        
         assertTrue(bindings.isEmpty());
        
         bindings = office3.getAllBindings();        
         assertTrue(bindings.isEmpty());                      
      }
      finally
      {
        if (office1 != null)
        {
          try
          {
            office1.stop();
          }
          catch (Exception ignore)
          {            
          }
        }

        if (office2 != null)
        {
          try
          {
            office2.stop();
          }
          catch (Exception ignore)
          {            
          }
        }

        if (office3 != null)
        {
          try
          {
            office3.stop();
          }        
          catch (Exception ignore)
          {            
          }
        }
View Full Code Here

    * g) take down one node
    * h) bring it back up
    * i) make sure it has quuee again
      * */
    
      PostOffice office1 = null;
      PostOffice office2 = null;
      PostOffice office3 = null;
     
      try
      {                         
         office1 = createClusteredPostOffice(1);
         office2 = createClusteredPostOffice(2);
         office3 = createClusteredPostOffice(3);        
                          
         //Durable
         Queue queue1 = new MessagingQueue(1, "sub1", channelIDManager.getID(), ms, pm, false, -1, null, true);
         queue1.activate();

         Condition condition1 = new SimpleCondition("condition1");
        
         //Add all binding
         boolean added = office1.addBinding(new Binding(condition1, queue1, true), true);
         assertTrue(added);
        
         Thread.sleep(3000);
         
         Collection bindings = office1.getAllBindings();        
         assertGotAll(1, bindings, queue1.getName());
        
         bindings = office2.getAllBindings();        
         assertGotAll(2, bindings, queue1.getName());
        
         bindings = office3.getAllBindings();        
         assertGotAll(3, bindings, queue1.getName());
        
         office1.stop();
         office2.stop();
         office3.stop();
     
         office1.start();
         office2.start();
         office3.start();
        
         Thread.sleep(3000);
        
         bindings = office1.getAllBindings();        
         assertTrue(bindings.isEmpty());
        
         bindings = office2.getAllBindings();        
         assertTrue(bindings.isEmpty());
        
         bindings = office3.getAllBindings();        
         assertTrue(bindings.isEmpty());
        
         added = office1.addBinding(new Binding(condition1, queue1, true), true);
         assertTrue(added);
        
         Thread.sleep(3000);
        
         bindings = office1.getAllBindings();        
         assertGotAll(1, bindings, queue1.getName());
        
         bindings = office2.getAllBindings();        
         assertGotAll(2, bindings, queue1.getName());
        
         bindings = office3.getAllBindings();        
         assertGotAll(3, bindings, queue1.getName());
        
         office3.stop();

         Thread.sleep(3000);
         
         bindings = office1.getAllBindings();        
         assertEquals(2, bindings.size());
        
         office3.start();

         Thread.sleep(3000);
        
         bindings = office1.getAllBindings();        
         assertGotAll(1, bindings, queue1.getName());
        
         bindings = office2.getAllBindings();        
         assertGotAll(2, bindings, queue1.getName());
        
         bindings = office3.getAllBindings();        
         assertGotAll(3, bindings, queue1.getName());                                                        
      }
      finally
      {
        if (office1 != null)
        {
          try
          {
            office1.stop();
          }
          catch (Exception ignore)
          {            
          }
        }

        if (office2 != null)
        {
          try
          {
            office2.stop();
          }
          catch (Exception ignore)
          {            
          }
        }

        if (office3 != null)
        {
          try
          {
            office3.stop();
          }        
          catch (Exception ignore)
          {            
          }
        }
View Full Code Here

     this.routeWithNonClusteredQueues(true);
   }
  
   public void testStartTxInternally() throws Throwable
   {
     PostOffice office1 = null;

     try
     {  
       office1 = createClusteredPostOffice(1);

       Queue queue1 =  new MessagingQueue(1, "queue1", channelIDManager.getID(), ms, pm, true, -1, null, true);
       queue1.activate();
       boolean added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queue1, false), false);
       assertTrue(added);
      
       Queue queue2 =  new MessagingQueue(1, "queue2", channelIDManager.getID(), ms, pm, true, -1, null, true);
       queue2.activate();
       added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queue2, false), false);
       assertTrue(added);
      
       Queue queue3 =  new MessagingQueue(1, "queue3", channelIDManager.getID(), ms, pm, true, -1, null, true);
       queue3.activate();
       added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queue3, false), false);
       assertTrue(added);
      
       Queue queue4 =  new MessagingQueue(1, "queue4", channelIDManager.getID(), ms, pm, true, -1, null, true);
       queue4.activate();
       added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queue4, false), false);
       assertTrue(added);

       SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
       queue1.getLocalDistributor().add(receiver1);

       SimpleReceiver receiver2 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
       queue2.getLocalDistributor().add(receiver2);

       SimpleReceiver receiver3 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
       queue3.getLocalDistributor().add(receiver3);
      
       SimpleReceiver receiver4 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
       queue4.getLocalDistributor().add(receiver4);

       Message msg1 = CoreMessageFactory.createCoreMessage(1, true, null);     
       MessageReference ref1 = ms.reference(msg1)
       RouteResult routed = office1.route(ref1, new SimpleCondition("condition1"), null);  
       assertTrue(routed.getResult());

       Message msg2 = CoreMessageFactory.createCoreMessage(2, true, null);     
       MessageReference ref2 = ms.reference(msg2);        
       routed = office1.route(ref2, new SimpleCondition("condition1"), null);     
       assertTrue(routed.getResult());

       Message msg3 = CoreMessageFactory.createCoreMessage(3, true, null);     
       MessageReference ref3 = ms.reference(msg3);        
       routed = office1.route(ref3, new SimpleCondition("condition1"), null);     
       assertTrue(routed.getResult());

       Thread.sleep(3000);
      
       List msgs = receiver1.getMessages();
       assertNotNull(msgs);
       assertEquals(3, msgs.size());
       Message msgRec1 = (Message)msgs.get(0);
       assertTrue(msg1 == msgRec1);
       Message msgRec2 = (Message)msgs.get(1);
       assertTrue(msg2 == msgRec2);
       Message msgRec3 = (Message)msgs.get(2);
       assertTrue(msg3 == msgRec3);

       receiver1.acknowledge(msgRec1, null);
       receiver1.acknowledge(msgRec2, null);
       receiver1.acknowledge(msgRec3, null);
       msgs = queue1.browse(null);
       assertNotNull(msgs);
       assertTrue(msgs.isEmpty());
      
       msgs = receiver2.getMessages();
       assertNotNull(msgs);
       assertEquals(3, msgs.size());
       msgRec1 = (Message)msgs.get(0);
       assertTrue(msg1 == msgRec1);
       msgRec2 = (Message)msgs.get(1);
       assertTrue(msg2 == msgRec2);
       msgRec3 = (Message)msgs.get(2);
       assertTrue(msg3 == msgRec3);

       receiver2.acknowledge(msgRec1, null);
       receiver2.acknowledge(msgRec2, null);
       receiver2.acknowledge(msgRec3, null);
       msgs = queue2.browse(null);
       assertNotNull(msgs);
       assertTrue(msgs.isEmpty());

       msgs = receiver3.getMessages();
       assertNotNull(msgs);
       assertEquals(3, msgs.size());
       msgRec1 = (Message)msgs.get(0);
       assertTrue(msg1 == msgRec1);
       msgRec2 = (Message)msgs.get(1);
       assertTrue(msg2 == msgRec2);
       msgRec3 = (Message)msgs.get(2);
       assertTrue(msg3 == msgRec3);

       receiver3.acknowledge(msgRec1, null);
       receiver3.acknowledge(msgRec2, null);
       receiver3.acknowledge(msgRec3, null);
       msgs = queue3.browse(null);
       assertNotNull(msgs);
       assertTrue(msgs.isEmpty());
      
       msgs = receiver4.getMessages();
       assertNotNull(msgs);
       assertEquals(3, msgs.size());
       msgRec1 = (Message)msgs.get(0);
       assertTrue(msg1 == msgRec1);
       msgRec2 = (Message)msgs.get(1);
       assertTrue(msg2 == msgRec2);
       msgRec3 = (Message)msgs.get(2);
       assertTrue(msg3 == msgRec3);

       receiver4.acknowledge(msgRec1, null);
       receiver4.acknowledge(msgRec2, null);
       receiver4.acknowledge(msgRec3, null);
       msgs = queue4.browse(null);
       assertNotNull(msgs);
       assertTrue(msgs.isEmpty());       
     }
     finally
     {
       if (office1 != null)
       {
            office1.removeBinding("queue1", true);
            office1.removeBinding("queue2", true);
            office1.removeBinding("queue3", true);
            office1.removeBinding("queue4", true);
            office1.stop();
       }
     }
   }
View Full Code Here

TOP

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

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.