Package org.jboss.test.messaging.core

Examples of org.jboss.test.messaging.core.SimpleCondition


     {  
       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)
       boolean routed = office1.route(ref1, new SimpleCondition("condition1"), null);  
       assertTrue(routed);

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

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

       Thread.sleep(3000);
      
       List msgs = receiver1.getMessages();
View Full Code Here


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

         Queue queue2 = new MessagingQueue(2, "queue1", channelIDManager.getID(), ms, pm, false, -1, null, true);
View Full Code Here

        
         //condition1

         queues[0] = new MessagingQueue(1, "sub1", channelIDManager.getID(), ms, pm, false, -1, null, true);
         queues[0].activate();
         boolean added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queues[0], false), false);
         assertTrue(added);
        
         queues[1] = new MessagingQueue(1, "sub2", channelIDManager.getID(), ms, pm, false, -1, null, true);
         queues[1].activate();
         added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queues[1], false), false);
         assertTrue(added);
        
         queues[2] = new MessagingQueue(2, "sub3", channelIDManager.getID(), ms, pm, false, -1, null, true);
         queues[2].activate();
         added = office2.addBinding(new Binding(new SimpleCondition("condition1"), queues[2], false), false);
         assertTrue(added);
        
         queues[3] = new MessagingQueue(2, "sub4", channelIDManager.getID(), ms, pm, false, -1, null, true);
         queues[3].activate();
         added = office2.addBinding(new Binding(new SimpleCondition("condition1"), queues[3], false), false);
         assertTrue(added);
        
         queues[4] = new MessagingQueue(2, "sub5", channelIDManager.getID(), ms, pm, true, -1, null, true);
         queues[4].activate();
         added = office2.addBinding(new Binding(new SimpleCondition("condition1"), queues[4], false), false);
         assertTrue(added);
        
         queues[5] = new MessagingQueue(1, "sub6", channelIDManager.getID(), ms, pm, false, -1, null, true);
         queues[5].activate();
         added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queues[5], false), false);
         assertTrue(added);
        
         queues[6] = new MessagingQueue(1, "sub7", channelIDManager.getID(), ms, pm, true, -1, null, true);
         queues[6].activate();
         added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queues[6], false), false);
         assertTrue(added);
        
         queues[7] = new MessagingQueue(1, "sub8", channelIDManager.getID(), ms, pm, true, -1, null, true);
         queues[7].activate();
         added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queues[7], false), false);
         assertTrue(added);
        
         //condition2
        
         queues[8] = new MessagingQueue(1, "sub9", channelIDManager.getID(), ms, pm, false, -1, null, true);
         queues[8].activate();
         added= office1.addBinding(new Binding(new SimpleCondition("condition2"), queues[8], false), false);
         assertTrue(added);
        
         queues[9] = new MessagingQueue(1, "sub10", channelIDManager.getID(), ms, pm, false, -1, null, true);
         queues[9].activate();
         added = office1.addBinding(new Binding(new SimpleCondition("condition2"), queues[9], false), false);
         assertTrue(added);
        
         queues[10] = new MessagingQueue(2, "sub11", channelIDManager.getID(), ms, pm, false, -1, null, true);
         queues[10].activate();
         added = office2.addBinding(new Binding(new SimpleCondition("condition2"), queues[10], false), false);
         assertTrue(added);
        
         queues[11] = new MessagingQueue(2, "sub12", channelIDManager.getID(), ms, pm, false, -1, null, true);
         queues[11].activate();
         added = office2.addBinding(new Binding(new SimpleCondition("condition2"), queues[11], false), false);
         assertTrue(added);
        
         queues[12] = new MessagingQueue(2, "sub13", channelIDManager.getID(), ms, pm, true, -1, null, true);
         queues[12].activate();
         added = office2.addBinding(new Binding(new SimpleCondition("condition2"), queues[12], false), false);
         assertTrue(added);
        
         queues[13] = new MessagingQueue(1, "sub14", channelIDManager.getID(), ms, pm, false, -1, null, true);
         queues[13].activate();
         added = office1.addBinding(new Binding(new SimpleCondition("condition2"), queues[13], false), false);
         assertTrue(added);
        
         queues[14] = new MessagingQueue(1, "sub15", channelIDManager.getID(), ms, pm, true, -1, null, true);
         queues[14].activate();
         added = office1.addBinding(new Binding(new SimpleCondition("condition2"), queues[14], false), false);
         assertTrue(added);
        
         queues[15] = new MessagingQueue(1, "sub16", channelIDManager.getID(), ms, pm, true, -1, null, true);
         queues[15].activate();
         added = office1.addBinding(new Binding(new SimpleCondition("condition2"), queues[15], false), false);
         assertTrue(added);

         SimpleReceiver[] receivers = new SimpleReceiver[16];
        
         for (int i = 0; i < 16; i++)
         {
            receivers[i] = new SimpleReceiver("blah" + i, SimpleReceiver.ACCEPTING);
            queues[i].getLocalDistributor().add(receivers[i]);
         }
        
         //First for topic 1
        
         Message msg1 = CoreMessageFactory.createCoreMessage(1, persistent, null);;     
         MessageReference ref1 = ms.reference(msg1);
        
         Message msg2 = CoreMessageFactory.createCoreMessage(2, persistent, null);;     
         MessageReference ref2 = ms.reference(msg2);
        
         Transaction tx = tr.createTransaction();

         boolean routed = office1.route(ref1, new SimpleCondition("condition1"), tx);        
         assertTrue(routed);
         routed = office1.route(ref2, new SimpleCondition("condition1"), tx);        
         assertTrue(routed);
        
         for (int i = 0; i < 16; i++)
         {
           log.info("i is " + i);
            List msgs = receivers[i].getMessages();
            assertNotNull(msgs);
            assertTrue(msgs.isEmpty());
            msgs = queues[i].browse(null);
            assertNotNull(msgs);
            assertTrue(msgs.isEmpty());
         }
        
         log.info("committing");
         tx.commit();
         log.info("committed");
        
         //Messages are sent asych so may take some finite time to arrive
         Thread.sleep(3000);
        
         for (int i = 0; i < 16; i++)
         {
           if (i >= 8 || (queues[i].getNodeID() == 2 && queues[i].isRecoverable()))
           {    
             //Shouldn't get message
             List msgs = receivers[i].getMessages();
             assertNotNull(msgs);
             assertTrue(msgs.isEmpty());
             msgs = queues[i].browse(null);
             assertNotNull(msgs);
             assertTrue(msgs.isEmpty());
           }
           else
           {
             //Should get message
             log.info("is is " + i);
             log.info("trying with receiver " + receivers[i]);
             List msgs = receivers[i].getMessages();
             assertNotNull(msgs);
             assertEquals(2, msgs.size());
             Message msgRec1 = (Message)msgs.get(0);
             assertEquals(msg1.getMessageID(), msgRec1.getMessageID());
             Message msgRec2 = (Message)msgs.get(1);
             assertEquals(msg2.getMessageID(), msgRec2.getMessageID());           
             receivers[i].acknowledge(msgRec1, null);
             receivers[i].acknowledge(msgRec2, null);
             msgs = queues[i].browse(null);
             assertNotNull(msgs);           
             assertTrue(msgs.isEmpty());                       
             receivers[i].clear();
           }
         }
        
         msg1 = CoreMessageFactory.createCoreMessage(1, persistent, null);;     
         ref1 = ms.reference(msg1);
        
         msg2 = CoreMessageFactory.createCoreMessage(2, persistent, null);;     
         ref2 = ms.reference(msg2);
        
         tx = tr.createTransaction();

         routed = office1.route(ref1, new SimpleCondition("condition1"), tx);        
         assertTrue(routed);
         routed = office1.route(ref2, new SimpleCondition("condition1"), tx);        
         assertTrue(routed);
        
         //Messages are sent asych so may take some finite time to arrive
         Thread.sleep(3000);        
        
         for (int i = 0; i < 16; i++)
         {
            List msgs = receivers[i].getMessages();
            assertNotNull(msgs);
            assertTrue(msgs.isEmpty());
            msgs = queues[i].browse(null);
            assertNotNull(msgs);
            assertTrue(msgs.isEmpty());
         }
        
         tx.rollback();
        
         for (int i = 0; i < 16; i++)
         {
            List msgs = receivers[i].getMessages();
            assertNotNull(msgs);
            assertTrue(msgs.isEmpty());
            msgs = queues[i].browse(null);
            assertNotNull(msgs);
            assertTrue(msgs.isEmpty());
         }
        
        
         // Now for topic 2
        
         msg1 = CoreMessageFactory.createCoreMessage(1, persistent, null);   
         ref1 = ms.reference(msg1);
        
         msg2 = CoreMessageFactory.createCoreMessage(2, persistent, null);    
         ref2 = ms.reference(msg2);
        
         tx = tr.createTransaction();

         routed = office2.route(ref1, new SimpleCondition("condition2"), tx);        
         assertTrue(routed);
         routed = office2.route(ref2, new SimpleCondition("condition2"), tx);        
         assertTrue(routed);
                          
         for (int i = 0; i < 16; i++)
         {
            List msgs = receivers[i].getMessages();
            assertNotNull(msgs);
            assertTrue(msgs.isEmpty());
            msgs = queues[i].browse(null);
            assertNotNull(msgs);
            assertTrue(msgs.isEmpty());
         }
        
         tx.commit();
        
         //Messages are sent asych so may take some finite time to arrive
         Thread.sleep(3000);
        
         for (int i = 8; i < 16; i++)
         {
           if (i < 8 || (queues[i].getNodeID() == 1 && queues[i].isRecoverable()))
          {    
             //  Shouldn't get message
            List msgs = receivers[i].getMessages();
            assertNotNull(msgs);
            assertTrue(msgs.isEmpty());
            msgs = queues[i].browse(null);
            assertNotNull(msgs);
            assertTrue(msgs.isEmpty());
          }
          else
          {
            // Should get message
            log.info("is is " + i);
            log.info("trying with receiver " + receivers[i]);
            List msgs = receivers[i].getMessages();
            assertNotNull(msgs);
            assertEquals(2, msgs.size());
            Message msgRec1 = (Message)msgs.get(0);
            assertEquals(msg1.getMessageID(), msgRec1.getMessageID());
            Message msgRec2 = (Message)msgs.get(1);
            assertEquals(msg2.getMessageID(), msgRec2.getMessageID());           
            receivers[i].acknowledge(msgRec1, null);
            receivers[i].acknowledge(msgRec2, null);
            msgs = queues[i].browse(null);
            assertNotNull(msgs);           
            assertTrue(msgs.isEmpty());                       
            receivers[i].clear();
          }
         }
              
         msg1 = CoreMessageFactory.createCoreMessage(1, persistent, null);;     
         ref1 = ms.reference(msg1);
        
         msg2 = CoreMessageFactory.createCoreMessage(2, persistent, null);;     
         ref2 = ms.reference(msg2);
        
         tx = tr.createTransaction();

         routed = office1.route(ref1, new SimpleCondition("condition1"), tx);        
         assertTrue(routed);
         routed = office1.route(ref2, new SimpleCondition("condition1"), tx);        
         assertTrue(routed);
        
         for (int i = 0; i < 16; i++)
         {
            List msgs = receivers[i].getMessages();
View Full Code Here

       SimpleFilter filter1 = new SimpleFilter(2);
       SimpleFilter filter2 = new SimpleFilter(3);

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

       Queue queue2 = new MessagingQueue(2, "queue2", channelIDManager.getID(), ms, pm, false, -1, filter2, true);
       queue2.activate();
       added = office2.addBinding(new Binding(new SimpleCondition("condition1"), queue2, false), false);
       assertTrue(added);

       Queue queue3 = new MessagingQueue(2, "queue3", channelIDManager.getID(), ms, pm, false, -1, null, true);
       queue3.activate();
       added = office2.addBinding(new Binding(new SimpleCondition("condition1"), queue3, 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);

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


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

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

       Thread.sleep(3000);

       List msgs = receiver1.getMessages();
View Full Code Here

       office3 = createClusteredPostOffice(3);
       office4 = createClusteredPostOffice(4);

       Queue queue1 =  new MessagingQueue(1, "queue1", channelIDManager.getID(), ms, pm, false, -1, null, true);
       queue1.activate();
       boolean added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queue1, false), false);
       assertTrue(added);
      
       Queue queue2 =  new MessagingQueue(2, "queue2", channelIDManager.getID(), ms, pm, false, -1, null, true);
       queue2.activate();
       added = office2.addBinding(new Binding(new SimpleCondition("condition1"), queue2, false), false);
       assertTrue(added);
      
       Queue queue3 =  new MessagingQueue(3, "queue3", channelIDManager.getID(), ms, pm, false, -1, null, true);
       queue3.activate();
       added = office3.addBinding(new Binding(new SimpleCondition("condition1"), queue3, false), false);
       assertTrue(added);
      
       Queue queue4 =  new MessagingQueue(4, "queue4", channelIDManager.getID(), ms, pm, false, -1, null, true);
       queue4.activate();
       added = office4.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, persistentMessage, null);     
       MessageReference ref1 = ms.reference(msg1)
       boolean routed = office1.route(ref1, new SimpleCondition("condition1"), null);  
       assertTrue(routed);

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

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

       Thread.sleep(3000);
      
       List msgs = receiver1.getMessages();
View Full Code Here

       //condition1

       queues[0] = new MessagingQueue(1, "sub1", channelIDManager.getID(), ms, pm, false, -1, null, true);
       queues[0].activate();
       boolean added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queues[0], false), false);
       assertTrue(added);

       queues[1] = new MessagingQueue(1, "sub2", channelIDManager.getID(), ms, pm, false, -1, null, true);
       queues[1].activate();
       added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queues[1], false), false);
       assertTrue(added);

       queues[2] = new MessagingQueue(2, "sub3", channelIDManager.getID(), ms, pm, false, -1, null, true);
       queues[2].activate();
       added = office2.addBinding(new Binding(new SimpleCondition("condition1"), queues[2], false), false);
       assertTrue(added);

       queues[3] = new MessagingQueue(2, "sub4", channelIDManager.getID(), ms, pm, false, -1, null, true);
       queues[3].activate();
       added = office2.addBinding(new Binding(new SimpleCondition("condition1"), queues[3], false), false);
       assertTrue(added);

       //durable

       queues[4] = new MessagingQueue(2, "sub5", channelIDManager.getID(), ms, pm, true, -1, null, true);
       queues[4].activate();
       added = office2.addBinding(new Binding(new SimpleCondition("condition1"), queues[4], false), false);
       assertTrue(added);

       queues[5] = new MessagingQueue(1, "sub6", channelIDManager.getID(), ms, pm, false, -1, null, true);
       queues[5].activate();
       added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queues[5], false), false);
       assertTrue(added);

       //durable

       queues[6] = new MessagingQueue(1, "sub7", channelIDManager.getID(), ms, pm, true, -1, null, true);
       queues[6].activate();
       added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queues[6], false), false);
       assertTrue(added);

       //durable

       queues[7] = new MessagingQueue(1, "sub8", channelIDManager.getID(), ms, pm, true, -1, null, true);
       queues[7].activate();
       added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queues[7], false), false);
       assertTrue(added);

       //condition2


       queues[8] = new MessagingQueue(1, "sub9", channelIDManager.getID(), ms, pm, false, -1, null, true);
       queues[8].activate();
       added = office1.addBinding(new Binding(new SimpleCondition("condition2"), queues[8], false), false);
       assertTrue(added);

       queues[9] = new MessagingQueue(1, "sub10", channelIDManager.getID(), ms, pm, false, -1, null, true);
       queues[9].activate();
       added = office1.addBinding(new Binding(new SimpleCondition("condition2"), queues[9], false), false);
       assertTrue(added);

       queues[10] = new MessagingQueue(2, "sub11", channelIDManager.getID(), ms, pm, false, -1, null, true);
       queues[10].activate();
       added = office2.addBinding(new Binding(new SimpleCondition("condition2"), queues[10], false), false);
       assertTrue(added);

       queues[11] = new MessagingQueue(2, "sub12", channelIDManager.getID(), ms, pm, false, -1, null, true);
       queues[11].activate();
       added = office2.addBinding(new Binding(new SimpleCondition("condition2"), queues[11], false), false);
       assertTrue(added);

       //durable

       queues[12] = new MessagingQueue(2, "sub13", channelIDManager.getID(), ms, pm, true, -1, null, true);
       queues[12].activate();
       added = office2.addBinding(new Binding(new SimpleCondition("condition2"), queues[12], false), false);
       assertTrue(added);

       queues[13] = new MessagingQueue(1, "sub14", channelIDManager.getID(), ms, pm, false, -1, null, true);
       queues[13].activate();
       added = office1.addBinding(new Binding(new SimpleCondition("condition2"), queues[13], false), false);
       assertTrue(added);

       //durable

       queues[14] = new MessagingQueue(1, "sub15", channelIDManager.getID(), ms, pm, true, -1, null, true);
       queues[14].activate();
       added = office1.addBinding(new Binding(new SimpleCondition("condition2"), queues[14], false), false);
       assertTrue(added);

       queues[15] = new MessagingQueue(1, "sub16", channelIDManager.getID(), ms, pm, true, -1, null, true);
       queues[15].activate();
       added = office1.addBinding(new Binding(new SimpleCondition("condition2"), queues[15], false), false);
       assertTrue(added);

       SimpleReceiver[] receivers = new SimpleReceiver[16];

       for (int i = 0; i < 16; i++)
       {
         receivers[i] = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         queues[i].getLocalDistributor().add(receivers[i]);
       }

       Message msg = CoreMessageFactory.createCoreMessage(1, persistentMessage, null);     
       MessageReference ref = ms.reference(msg);        

       boolean routed = office1.route(ref, new SimpleCondition("condition1"), null);        
       assertTrue(routed);

       //Messages are sent asych so may take some finite time to arrive
       Thread.sleep(3000);

       //Durable queues on remote node should never get the message

       for (int i = 0; i < 16; i++)
       {
         if (i >= 8 || (queues[i].getNodeID() == 2 && queues[i].isRecoverable()))
         {
           this.checkNotGetsMessage(queues[i], receivers[i]);
         }
         else
         {
           //Should get the message
           this.checkGetsMessage(queues[i], receivers[i], msg);
         }

       }

       //Now route to condition2

       msg = CoreMessageFactory.createCoreMessage(2, persistentMessage, null);;     
       ref = ms.reference(msg);        

       routed = office2.route(ref, new SimpleCondition("condition2"), null);        
       assertTrue(routed);
       //Messages are sent asych so may take some finite time to arrive
       Thread.sleep(3000);

       for (int i = 0; i < 16; i++)
View Full Code Here

       //condition1

       queues[0] = new MessagingQueue(1, "sub1", channelIDManager.getID(), ms, pm, false, -1, null, false);
       queues[0].activate();
       boolean added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queues[0], false), false);
       assertTrue(added);

       queues[1] = new MessagingQueue(1, "sub2", channelIDManager.getID(), ms, pm, false, -1, null, true);
       queues[1].activate();
       added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queues[1], false), false);
       assertTrue(added);

       queues[2] = new MessagingQueue(2, "sub3", channelIDManager.getID(), ms, pm, false, -1, null, false);
       queues[2].activate();
       added = office2.addBinding(new Binding(new SimpleCondition("condition1"), queues[2], false), false);
       assertTrue(added);

       queues[3] = new MessagingQueue(2, "sub4", channelIDManager.getID(), ms, pm, false, -1, null, true);
       queues[3].activate();
       added = office2.addBinding(new Binding(new SimpleCondition("condition1"), queues[3], false), false);
       assertTrue(added);

       queues[4] = new MessagingQueue(2, "sub5", channelIDManager.getID(), ms, pm, true, -1, null, false);
       queues[4].activate();
       added = office2.addBinding(new Binding(new SimpleCondition("condition1"), queues[4], false), false);
       assertTrue(added);

       queues[5] = new MessagingQueue(1, "sub6", channelIDManager.getID(), ms, pm, false, -1, null, true);
       queues[5].activate();
       added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queues[5], false), false);
       assertTrue(added);

       queues[6] = new MessagingQueue(1, "sub7", channelIDManager.getID(), ms, pm, true, -1, null, false);
       queues[6].activate();
       added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queues[6], false), false);
       assertTrue(added);

       queues[7] = new MessagingQueue(1, "sub8", channelIDManager.getID(), ms, pm, true, -1, null, true);
       queues[7].activate();
       added = office1.addBinding(new Binding(new SimpleCondition("condition1"), queues[7], false), false);
       assertTrue(added);

       //condition2


       queues[8] = new MessagingQueue(1, "sub9", channelIDManager.getID(), ms, pm, false, -1, null, false);
       queues[8].activate();
       added = office1.addBinding(new Binding(new SimpleCondition("condition2"), queues[8], false), false);
       assertTrue(added);

       queues[9] = new MessagingQueue(1, "sub10", channelIDManager.getID(), ms, pm, false, -1, null, true);
       queues[9].activate();
       added = office1.addBinding(new Binding(new SimpleCondition("condition2"), queues[9], false), false);
       assertTrue(added);

       queues[10] = new MessagingQueue(2, "sub11", channelIDManager.getID(), ms, pm, false, -1, null, false);
       queues[10].activate();
       added = office2.addBinding(new Binding(new SimpleCondition("condition2"), queues[10], false), false);
       assertTrue(added);

       queues[11] = new MessagingQueue(2, "sub12", channelIDManager.getID(), ms, pm, false, -1, null, true);
       queues[11].activate();
       added = office2.addBinding(new Binding(new SimpleCondition("condition2"), queues[11], false), false);
       assertTrue(added);

       queues[12] = new MessagingQueue(2, "sub13", channelIDManager.getID(), ms, pm, true, -1, null, false);
       queues[12].activate();
       added = office2.addBinding(new Binding(new SimpleCondition("condition2"), queues[12], false), false);
       assertTrue(added);

       queues[13] = new MessagingQueue(1, "sub14", channelIDManager.getID(), ms, pm, false, -1, null, true);
       queues[13].activate();
       added = office1.addBinding(new Binding(new SimpleCondition("condition2"), queues[13], false), false);
       assertTrue(added);

       queues[14] = new MessagingQueue(1, "sub15", channelIDManager.getID(), ms, pm, true, -1, null, false);
       queues[14].activate();
       added = office1.addBinding(new Binding(new SimpleCondition("condition2"), queues[14], false), false);
       assertTrue(added);

       queues[15] = new MessagingQueue(1, "sub16", channelIDManager.getID(), ms, pm, true, -1, null, true);
       queues[15].activate();
       added = office1.addBinding(new Binding(new SimpleCondition("condition2"), queues[15], false), false);
       assertTrue(added);

       SimpleReceiver[] receivers = new SimpleReceiver[16];

       for (int i = 0; i < 16; i++)
       {
         receivers[i] = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         queues[i].getLocalDistributor().add(receivers[i]);
       }

       Message msg = CoreMessageFactory.createCoreMessage(1, persistentMessage, null);     
       MessageReference ref = ms.reference(msg);        

       boolean routed = office1.route(ref, new SimpleCondition("condition1"), null);        
       assertTrue(routed);

       //Messages are sent asych so may take some finite time to arrive
       Thread.sleep(3000);

       //Durable queues on remote node should never get the message - neither should non clustered ones

       for (int i = 0; i < 16; i++)
       {
         if (i >= 8 || (queues[i].getNodeID() == 2 && queues[i].isRecoverable())
             || (queues[i].getNodeID() == 2 && !queues[i].isClustered()))
         {
           this.checkNotGetsMessage(queues[i], receivers[i]);
         }
         else
         {
           //Should get the message
           this.checkGetsMessage(queues[i], receivers[i], msg);
         }
       }

       //Now route to condition2

       msg = CoreMessageFactory.createCoreMessage(2, persistentMessage, null);;     
       ref = ms.reference(msg);        

       routed = office2.route(ref, new SimpleCondition("condition2"), null);        
       assertTrue(routed);
       //Messages are sent asych so may take some finite time to arrive
       Thread.sleep(3000);

       for (int i = 0; i < 16; i++)
View Full Code Here

       //queue1

       Queue queue0 = new MessagingQueue(1, "myqueue1", channelIDManager.getID(), ms, pm, false, -1, null, true);
       queue0.activate();
       boolean added = office1.addBinding(new Binding(new SimpleCondition("myqueue1"), queue0, false), false);
       assertTrue(added);

       Queue queue1 = new MessagingQueue(2, "myqueue1", channelIDManager.getID(), ms, pm, false, -1, null, true);
       queue1.activate();
       added = office2.addBinding(new Binding(new SimpleCondition("myqueue1"), queue1, false), false);
       assertTrue(added);


       //queue2

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

       Queue queue3 = new MessagingQueue(2, "myqueue2", channelIDManager.getID(), ms, pm, false, -1, null, true);
       queue3.activate();
       added = office2.addBinding(new Binding(new SimpleCondition("myqueue2"), queue3, false), false);
       assertTrue(added);


       SimpleReceiver receiver0 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
       queue0.getLocalDistributor().add(receiver0);

       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);

       //Route to myqueue1 from office1        

       Message msg = CoreMessageFactory.createCoreMessage(1, persistentMessage, null);     
       MessageReference ref = ms.reference(msg);        

       boolean routed = office1.route(ref, new SimpleCondition("myqueue1"), null);        
       assertTrue(routed);

       //Messages are sent asych so may take some finite time to arrive
       Thread.sleep(3000);

       //Only queue0 should get the message
       checkGetsMessage(queue0, receiver0, msg);

       checkNotGetsMessage(queue1, receiver1);

       checkNotGetsMessage(queue2, receiver2);

       checkNotGetsMessage(queue3, receiver3);

       //  Route to myqueue1 from office 2     

       msg = CoreMessageFactory.createCoreMessage(2, persistentMessage, null);     
       ref = ms.reference(msg);        

       routed = office2.route(ref, new SimpleCondition("myqueue1"), null);        
       assertTrue(routed);

       //Messages are sent asych so may take some finite time to arrive
       Thread.sleep(3000);

       //Only queue1 should get the message
       checkGetsMessage(queue1, receiver1, msg);

       checkNotGetsMessage(queue0, receiver0);

       checkNotGetsMessage(queue2, receiver2);

       checkNotGetsMessage(queue3, receiver3);


       //Now route to condition2 from office 1

       msg = CoreMessageFactory.createCoreMessage(3, persistentMessage, null);;     
       ref = ms.reference(msg);        

       routed = office1.route(ref, new SimpleCondition("myqueue2"), null);        
       assertTrue(routed);
       //Messages are sent asych so may take some finite time to arrive
       Thread.sleep(3000);

       // Only queue2 should get the message
       checkGetsMessage(queue2, receiver2, msg);

       checkNotGetsMessage(queue1, receiver1);

       checkNotGetsMessage(queue0, receiver0);

       checkNotGetsMessage(queue3, receiver3);


       //Now route to condition2 from office 2

       msg = CoreMessageFactory.createCoreMessage(4, persistentMessage, null);;     
       ref = ms.reference(msg);        

       routed = office2.route(ref, new SimpleCondition("myqueue2"), null);        
       assertTrue(routed);
       //Messages are sent asych so may take some finite time to arrive
       Thread.sleep(3000);

       // Only queue3 should get the message
View Full Code Here

       office2 = createClusteredPostOffice(2);


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

       Queue queue1 = new MessagingQueue(2, "sub2", channelIDManager.getID(), ms, pm, false, -1, null, true);
       queue1.activate();
       added = office2.addBinding(new Binding(new SimpleCondition("condition1"), queue1, false), false);
       assertTrue(added);


       Queue queue2 = new MessagingQueue(1, "sub3", channelIDManager.getID(), ms, pm, false, -1, null, true);
       queue2.activate();
       added = office1.addBinding(new Binding(new SimpleCondition("condition2"), queue2, false), false);
       assertTrue(added);

       Queue queue3 = new MessagingQueue(2, "sub4", channelIDManager.getID(), ms, pm, false, -1, null, true);
       queue3.activate();
       added = office2.addBinding(new Binding(new SimpleCondition("condition2"), queue3, false), false);
       assertTrue(added);


       SimpleReceiver receiver0 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
       queue0.getLocalDistributor().add(receiver0);

       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);

       //Route to condition1 from office1        

       Message msg = CoreMessageFactory.createCoreMessage(1, persistentMessage, null);     
       MessageReference ref = ms.reference(msg);        

       boolean routed = office1.route(ref, new SimpleCondition("myqueue1"), null);        
       assertTrue(routed);

       //Messages are sent asych so may take some finite time to arrive
       Thread.sleep(3000);

       //Only queue0 should get the message
       checkGetsMessage(queue0, receiver0, msg);

       checkNotGetsMessage(queue1, receiver1);

       checkNotGetsMessage(queue2, receiver2);

       checkNotGetsMessage(queue3, receiver3);

       //  Route to myqueue1 from office 2     

       msg = CoreMessageFactory.createCoreMessage(2, persistentMessage, null);     
       ref = ms.reference(msg);        

       routed = office2.route(ref, new SimpleCondition("myqueue1"), null);        
       assertTrue(routed);

       //Messages are sent asych so may take some finite time to arrive
       Thread.sleep(3000);

       //Only queue1 should get the message
       checkGetsMessage(queue1, receiver1, msg);

       checkNotGetsMessage(queue0, receiver0);

       checkNotGetsMessage(queue2, receiver2);

       checkNotGetsMessage(queue3, receiver3);


       //Now route to condition2 from office 1

       msg = CoreMessageFactory.createCoreMessage(3, persistentMessage, null);;     
       ref = ms.reference(msg);        

       routed = office1.route(ref, new SimpleCondition("myqueue2"), null);        
       assertTrue(routed);
       //Messages are sent asych so may take some finite time to arrive
       Thread.sleep(3000);

       // Only queue2 should get the message
       checkGetsMessage(queue2, receiver2, msg);

       checkNotGetsMessage(queue1, receiver1);

       checkNotGetsMessage(queue0, receiver0);

       checkNotGetsMessage(queue3, receiver3);


       //Now route to condition2 from office 2

       msg = CoreMessageFactory.createCoreMessage(4, persistentMessage, null);;     
       ref = ms.reference(msg);        

       routed = office2.route(ref, new SimpleCondition("myqueue2"), null);        
       assertTrue(routed);
       //Messages are sent asych so may take some finite time to arrive
       Thread.sleep(3000);

       // Only queue3 should get the message
View Full Code Here

            
         MessagingQueue queue1 =
            new MessagingQueue(1, "durableQueue", channelIDManager.getID(), ms, pm, true, -1, null, false);
         queue1.activate();
        
         Condition condition1 = new SimpleCondition("condition1");
                 
         boolean added = office1.addBinding(new Binding(condition1, queue1, false), false);
         assertTrue(added);
        
         //Binding twice with the same name should fail     
         added = office1.addBinding(new Binding(condition1, queue1, false), false);
         assertFalse(added);
        
         //Can't bind a queue from another node
        
         try
         {
        
           MessagingQueue queuexx =
              new MessagingQueue(777, "durableQueue", channelIDManager.getID(), ms, pm, true, -1, null, false);
           queuexx.activate();
           office1.addBinding(new Binding(condition1, queuexx, false), false);
            fail();
         }
         catch (IllegalArgumentException e)
         {
            //Ok
         }
        
              
         //Bind one non durable
         MessagingQueue queue2 =
            new MessagingQueue(1, "nonDurableQueue", channelIDManager.getID(), ms, pm, false, -1, null, false);
         queue2.activate();
        
         Condition condition2 = new SimpleCondition("condition2");        
        
         added = office1.addBinding(new Binding(condition2, queue2, false), false);
         assertTrue(added);
        
         //Check they're there
View Full Code Here

TOP

Related Classes of org.jboss.test.messaging.core.SimpleCondition

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.