Package org.jboss.test.messaging.core

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


     
         LocalClusteredQueue queue1 =
            new LocalClusteredQueue(office1, 1, "queue1", channelIDManager.getID(), ms, pm,
                                    true, recoverable, -1, filter1, tr);

         office1.bindClusteredQueue(new SimpleCondition("topic1"), queue1);
        
         LocalClusteredQueue queue2 =
            new LocalClusteredQueue(office2, 2, "queue2", channelIDManager.getID(), ms, pm,
                                    true, recoverable, -1, filter2, tr);

         office2.bindClusteredQueue(new SimpleCondition("topic1"), queue2);
        
         LocalClusteredQueue queue3 =
            new LocalClusteredQueue(office2, 2, "queue3", channelIDManager.getID(), ms, pm, true,
                                    recoverable, -1, null, tr);

         office2.bindClusteredQueue(new SimpleCondition("topic1"), queue3);
        
         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);
        
         Message msg1 = CoreMessageFactory.createCoreMessage(1);     
         MessageReference ref1 = ms.reference(msg1)
         boolean routed = office1.route(ref1, new SimpleCondition("topic1"), null);  
         assertTrue(routed);
        
        
         Message msg2 = CoreMessageFactory.createCoreMessage(2);     
         MessageReference ref2 = ms.reference(msg2);        
         routed = office1.route(ref2, new SimpleCondition("topic1"), null);     
         assertTrue(routed);
        
         Message msg3 = CoreMessageFactory.createCoreMessage(3);     
         MessageReference ref3 = ms.reference(msg3);        
         routed = office1.route(ref3, new SimpleCondition("topic1"), null);     
         assertTrue(routed);
        
         Thread.sleep(2000);
        
         List msgs = receiver1.getMessages();
View Full Code Here


        
         LocalClusteredQueue[] queues = new LocalClusteredQueue[16];
         Binding[] bindings = new Binding[16];
        
         queues[0] = new LocalClusteredQueue(office1, 1, "sub1", channelIDManager.getID(), ms, pm, true, false, -1, null, tr);
         bindings[0] = office1.bindClusteredQueue(new SimpleCondition("topic1"), queues[0]);
        
         queues[1] = new LocalClusteredQueue(office1, 1, "sub2", channelIDManager.getID(), ms, pm, true, false, -1, null, tr);
         bindings[1] = office1.bindClusteredQueue(new SimpleCondition("topic1"), queues[1]);
        
         queues[2] = new LocalClusteredQueue(office2, 2, "sub3", channelIDManager.getID(), ms, pm, true, false, -1, null, tr);
         bindings[2] = office2.bindClusteredQueue(new SimpleCondition("topic1"), queues[2]);
        
         queues[3] = new LocalClusteredQueue(office2, 2, "sub4", channelIDManager.getID(), ms, pm, true, false, -1, null, tr);
         bindings[3] = office2.bindClusteredQueue(new SimpleCondition("topic1"), queues[3]);
        
         queues[4] = new LocalClusteredQueue(office2, 2, "sub5", channelIDManager.getID(), ms, pm, true, true, -1, null, tr);
         bindings[4] = office2.bindClusteredQueue(new SimpleCondition("topic1"), queues[4]);
        
         queues[5] = new LocalClusteredQueue(office1, 1, "sub6", channelIDManager.getID(), ms, pm, true, false, -1, null, tr);
         bindings[5] = office1.bindClusteredQueue(new SimpleCondition("topic1"), queues[5]);
        
         queues[6] = new LocalClusteredQueue(office1, 1, "sub7", channelIDManager.getID(), ms, pm, true, true, -1, null, tr);
         bindings[6] = office1.bindClusteredQueue(new SimpleCondition("topic1"), queues[6]);
        
         queues[7] = new LocalClusteredQueue(office1, 1, "sub8", channelIDManager.getID(), ms, pm, true, true, -1, null, tr);
         bindings[7] = office1.bindClusteredQueue(new SimpleCondition("topic1"), queues[7]);
        
         queues[8] = new LocalClusteredQueue(office1, 1, "sub9", channelIDManager.getID(), ms, pm, true, false, -1, null, tr);
         bindings[8] = office1.bindClusteredQueue(new SimpleCondition("topic2"), queues[8]);
        
         queues[9] = new LocalClusteredQueue(office1, 1, "sub10", channelIDManager.getID(), ms, pm, true, false, -1, null, tr);
         bindings[9] = office1.bindClusteredQueue(new SimpleCondition("topic2"), queues[9]);
        
         queues[10] = new LocalClusteredQueue(office2, 2, "sub11", channelIDManager.getID(), ms, pm, true, false, -1, null, tr);
         bindings[10] = office2.bindClusteredQueue(new SimpleCondition("topic2"), queues[10]);
        
         queues[11] = new LocalClusteredQueue(office2, 2, "sub12", channelIDManager.getID(), ms, pm, true, false, -1, null, tr);
         bindings[11] = office2.bindClusteredQueue(new SimpleCondition("topic2"), queues[11]);
        
         queues[12] = new LocalClusteredQueue(office2, 2, "sub13", channelIDManager.getID(), ms, pm, true, true, -1, null, tr);
         bindings[12] = office2.bindClusteredQueue(new SimpleCondition("topic2"), queues[12]);
        
         queues[13] = new LocalClusteredQueue(office1, 1, "sub14", channelIDManager.getID(), ms, pm, true, false, -1, null, tr);
         bindings[13] = office1.bindClusteredQueue(new SimpleCondition("topic2"), queues[13]);
        
         queues[14] = new LocalClusteredQueue(office1, 1, "sub15", channelIDManager.getID(), ms, pm, true, true, -1, null, tr);
         bindings[14] = office1.bindClusteredQueue(new SimpleCondition("topic2"), queues[14]);
        
         queues[15] = new LocalClusteredQueue(office1, 1, "sub16", channelIDManager.getID(), ms, pm, true, true, -1, null, tr);
         bindings[15] = office1.bindClusteredQueue(new SimpleCondition("topic2"), queues[15]);
      
         SimpleReceiver[] receivers = new SimpleReceiver[16];
        
         for (int i = 0; i < 16; i++)
         {
            receivers[i] = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
            queues[i].add(receivers[i]);
         }
        
         Message msg = CoreMessageFactory.createCoreMessage(1, persistentMessage, null);     
         MessageReference ref = ms.reference(msg);        

         boolean routed = office1.route(ref, new SimpleCondition("topic1"), null);        
         assertTrue(routed);
        
         //Messages are sent asych so may take some finite time to arrive
         Thread.sleep(1000);
        
         for (int i = 0; i < 8; i++)
         {        
            List msgs = receivers[i].getMessages();
            assertNotNull(msgs);
            assertEquals(1, msgs.size());
            Message msgRec = (Message)msgs.get(0);
            assertEquals(msg.getMessageID(), msgRec.getMessageID());
            receivers[i].acknowledge(msgRec, null);
            msgs = queues[i].browse();
            assertNotNull(msgs);
            assertTrue(msgs.isEmpty());
            receivers[i].clear();
         }
        
         for (int i = 8; i < 16; i++)
         {
            List msgs = receivers[i].getMessages();
            assertNotNull(msgs);
            assertTrue(msgs.isEmpty());
            msgs = queues[i].browse();
            assertNotNull(msgs);
            assertTrue(msgs.isEmpty());
         }
                 
         //Now route to topic2
        
         msg = CoreMessageFactory.createCoreMessage(2, persistentMessage, null);;     
         ref = ms.reference(msg);        

         routed = office1.route(ref, new SimpleCondition("topic2"), null);        
         assertTrue(routed);
         //Messages are sent asych so may take some finite time to arrive
         Thread.sleep(1000);
        
         for (int i = 0; i < 8; i++)
View Full Code Here

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

         office1.bindClusteredQueue(new SimpleCondition("queue1"), queue1);

         SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         queue1.add(receiver1);
        
         LocalClusteredQueue queue2 =
            new LocalClusteredQueue(office2, 2, "queue1", channelIDManager.getID(), ms, pm, true,
                                    recoverable, -1, null, tr);

         office2.bindClusteredQueue(new SimpleCondition("queue1"), queue2);

         SimpleReceiver receiver2 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         queue2.add(receiver2);
        
         LocalClusteredQueue queue3 =
            new LocalClusteredQueue(office3, 3, "queue1", channelIDManager.getID(), ms, pm, true,
                                    recoverable, -1, null, tr);

         office3.bindClusteredQueue(new SimpleCondition("queue1"), queue3);

         SimpleReceiver receiver3 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         queue3.add(receiver3);
        
         LocalClusteredQueue queue4 =
            new LocalClusteredQueue(office4, 4, "queue1", channelIDManager.getID(), ms, pm,
                                    true, recoverable, -1, null, tr);

         office4.bindClusteredQueue(new SimpleCondition("queue1"), queue4);

         SimpleReceiver receiver4 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         queue4.add(receiver4);
        
         LocalClusteredQueue queue5 =
            new LocalClusteredQueue(office5, 5, "queue1", channelIDManager.getID(), ms, pm, true,
                                    recoverable, -1, null, tr);

         office5.bindClusteredQueue(new SimpleCondition("queue1"), queue5);
         SimpleReceiver receiver5 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         queue5.add(receiver5);
       
         // We are using a AlwaysLocalRoutingPolicy so only the local queue should ever get the
         // message if the filter matches
                         
         Message msg = CoreMessageFactory.createCoreMessage(1, persistentMessage, null);     
         MessageReference ref = ms.reference(msg);        
         boolean routed = office1.route(ref, new SimpleCondition("queue1"), null);        
         assertTrue(routed);
         checkContainsAndAcknowledge(msg, receiver1, queue1);
         this.checkEmpty(receiver2);
         this.checkEmpty(receiver3);
         this.checkEmpty(receiver4);
         this.checkEmpty(receiver5);
        
         msg = CoreMessageFactory.createCoreMessage(1, persistentMessage, null);     
         ref = ms.reference(msg);        
         routed = office2.route(ref, new SimpleCondition("queue1"), null);        
         assertTrue(routed);
         this.checkEmpty(receiver1);
         checkContainsAndAcknowledge(msg, receiver2, queue2);
         this.checkEmpty(receiver3);
         this.checkEmpty(receiver4);
         this.checkEmpty(receiver5);
        
         msg = CoreMessageFactory.createCoreMessage(1, persistentMessage, null);     
         ref = ms.reference(msg);        
         routed = office3.route(ref, new SimpleCondition("queue1"), null);        
         assertTrue(routed);
         this.checkEmpty(receiver1);
         this.checkEmpty(receiver2);
         checkContainsAndAcknowledge(msg, receiver3, queue3);
         this.checkEmpty(receiver4);
         this.checkEmpty(receiver5);
        
         msg = CoreMessageFactory.createCoreMessage(1, persistentMessage, null);     
         ref = ms.reference(msg);        
         routed = office4.route(ref, new SimpleCondition("queue1"), null);        
         assertTrue(routed);
         this.checkEmpty(receiver1);
         this.checkEmpty(receiver2);
         this.checkEmpty(receiver3);
         checkContainsAndAcknowledge(msg, receiver4, queue3);
         this.checkEmpty(receiver5);
        
         msg = CoreMessageFactory.createCoreMessage(1, persistentMessage, null);     
         ref = ms.reference(msg);        
         routed = office5.route(ref, new SimpleCondition("queue1"), null);        
         assertTrue(routed);
         this.checkEmpty(receiver1);
         this.checkEmpty(receiver2);        
         this.checkEmpty(receiver3);
         this.checkEmpty(receiver4);
         checkContainsAndAcknowledge(msg, receiver5, queue5);
        
         msg = CoreMessageFactory.createCoreMessage(1, persistentMessage, null);     
         ref = ms.reference(msg);        
         routed = office6.route(ref, new SimpleCondition("queue1"), null);        
         assertTrue(routed);
        
         //The actual queue that receives the mesage is determined by the routing policy
         //The default uses round robin for the nodes (this is tested more thoroughly in
         //its own test)
View Full Code Here

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

         office1.bindQueue(new SimpleCondition("topic"), sub1);

         SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         sub1.add(receiver1);
        
         LocalClusteredQueue sub2 =
            new LocalClusteredQueue(office2, 2, "sub2", channelIDManager.getID(), ms, pm, true,
                                    recoverable, -1, null, tr);

         office2.bindQueue(new SimpleCondition("topic"), sub2);
         SimpleReceiver receiver2 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         sub2.add(receiver2);
        
         LocalClusteredQueue sub3 =
            new LocalClusteredQueue(office3, 3, "sub3", channelIDManager.getID(), ms, pm, true,
                                    recoverable, -1, null, tr);

         office3.bindQueue(new SimpleCondition("topic"), sub3);
         SimpleReceiver receiver3 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         sub3.add(receiver3);
        
         //Only the local sub should get it since we have bound locally
        
         Message msg = CoreMessageFactory.createCoreMessage(1, persistentMessage, null);     
         MessageReference ref = ms.reference(msg);        
         boolean routed = office1.route(ref, new SimpleCondition("topic"), null);        
         assertTrue(routed);        
         Thread.sleep(500);        
         checkContainsAndAcknowledge(msg, receiver1, sub1);
         this.checkEmpty(receiver2);
         this.checkEmpty(receiver3);
        
         msg = CoreMessageFactory.createCoreMessage(2, persistentMessage, null);     
         ref = ms.reference(msg);        
         routed = office2.route(ref, new SimpleCondition("topic"), null);        
         assertTrue(routed);                 
         Thread.sleep(500);
         this.checkEmpty(receiver1);
         checkContainsAndAcknowledge(msg, receiver2, sub2);
         this.checkEmpty(receiver3);
        
         msg = CoreMessageFactory.createCoreMessage(3, persistentMessage, null);     
         ref = ms.reference(msg);        
         routed = office3.route(ref, new SimpleCondition("topic"), null);          
         assertTrue(routed);        
         Thread.sleep(500);
         this.checkEmpty(receiver1);        
         this.checkEmpty(receiver2);
         checkContainsAndAcknowledge(msg, receiver3, sub2);          
View Full Code Here

         // Non durable 1 on node 2
         LocalClusteredQueue nonDurable1 =
            new LocalClusteredQueue(office2, 2, "nondurable1", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);

         office2.bindClusteredQueue(new SimpleCondition("topic"), nonDurable1);
         SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         nonDurable1.add(receiver1);
        
         // Non durable 2 on node 2
         LocalClusteredQueue nonDurable2 =
            new LocalClusteredQueue(office2, 2, "nondurable2", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);

         office2.bindClusteredQueue(new SimpleCondition("topic"), nonDurable2);
         SimpleReceiver receiver2 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         nonDurable2.add(receiver2);
        
         //Node 3
         //======
        
         // Non shared durable
         LocalClusteredQueue nonSharedDurable1 =
            new LocalClusteredQueue(office3, 3, "nonshareddurable1", channelIDManager.getID(), ms,
                                    pm, true, true, -1, null, tr);

         office3.bindClusteredQueue(new SimpleCondition("topic"), nonSharedDurable1);
         SimpleReceiver receiver3 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         nonSharedDurable1.add(receiver3);
        
         // Non durable
         LocalClusteredQueue nonDurable3 =
            new LocalClusteredQueue(office3, 3, "nondurable3", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);

         office3.bindClusteredQueue(new SimpleCondition("topic"), nonDurable3);
         SimpleReceiver receiver4 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         nonDurable3.add(receiver4);
        
         //Node 4
         //======
        
         // Shared durable
         LocalClusteredQueue sharedDurable1 =
            new LocalClusteredQueue(office4, 4, "shareddurable1", channelIDManager.getID(), ms, pm,
                                    true, true, -1, null, tr);

         office4.bindClusteredQueue(new SimpleCondition("topic"), sharedDurable1);
         SimpleReceiver receiver5 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         sharedDurable1.add(receiver5);
        
         // Non shared durable
         LocalClusteredQueue nonSharedDurable2 =
            new LocalClusteredQueue(office4, 4, "nonshareddurable2", channelIDManager.getID(), ms,
                                    pm, true, true, -1, null, tr);

         office4.bindClusteredQueue(new SimpleCondition("topic"), nonSharedDurable2);
         SimpleReceiver receiver6 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         nonSharedDurable2.add(receiver6);
        
         // Non durable
         LocalClusteredQueue nonDurable4 =
            new LocalClusteredQueue(office4, 4, "nondurable4", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);

         office4.bindClusteredQueue(new SimpleCondition("topic"), nonDurable4);
         SimpleReceiver receiver7 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         nonDurable4.add(receiver7);
        
         // Non durable
         LocalClusteredQueue nonDurable5 =
            new LocalClusteredQueue(office4, 4, "nondurable5", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);
         office4.bindClusteredQueue(new SimpleCondition("topic"), nonDurable5);
         SimpleReceiver receiver8 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         nonDurable5.add(receiver8);
        
         // Non durable
         LocalClusteredQueue nonDurable6 =
            new LocalClusteredQueue(office4, 4, "nondurable6", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);
         office4.bindClusteredQueue(new SimpleCondition("topic"), nonDurable6);
         SimpleReceiver receiver9 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         nonDurable6.add(receiver9);
        
         // Node 5
         //=======
         // Shared durable
         LocalClusteredQueue sharedDurable2 =
            new LocalClusteredQueue(office5, 5, "shareddurable1", channelIDManager.getID(), ms, pm,
                                    true, true, -1, null, tr);

         office5.bindClusteredQueue(new SimpleCondition("topic"), sharedDurable2);
         SimpleReceiver receiver10 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         sharedDurable2.add(receiver10);
        
         // Shared durable
         LocalClusteredQueue sharedDurable3 =
            new LocalClusteredQueue(office5, 5, "shareddurable2", channelIDManager.getID(), ms, pm,
                                    true, true, -1, null, tr);

         office5.bindClusteredQueue(new SimpleCondition("topic"), sharedDurable3);
         SimpleReceiver receiver11 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         sharedDurable3.add(receiver11);
        
         // Node 6
         //=========
         LocalClusteredQueue sharedDurable4 =
            new LocalClusteredQueue(office6, 6, "shareddurable2", channelIDManager.getID(), ms, pm,
                                    true, true, -1, null, tr);

         office6.bindClusteredQueue(new SimpleCondition("topic"), sharedDurable4);
         SimpleReceiver receiver12 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         sharedDurable4.add(receiver12);
        
         LocalClusteredQueue nonDurable7 =
            new LocalClusteredQueue(office6, 6, "nondurable7", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);
         office6.bindClusteredQueue(new SimpleCondition("topic"), nonDurable7);
         SimpleReceiver receiver13 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         nonDurable7.add(receiver13);
        
         //Node 7
         //=======
         LocalClusteredQueue sharedDurable5 =
            new LocalClusteredQueue(office7, 7, "shareddurable2", channelIDManager.getID(), ms, pm,
                                    true, true, -1, null, tr);

         office7.bindClusteredQueue(new SimpleCondition("topic"), sharedDurable5);
         SimpleReceiver receiver14 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         sharedDurable5.add(receiver14);
        
        
         //Send 1 message at node1
View Full Code Here

         Binding[] bindings = new Binding[16];
        
         queues[0] =
            new LocalClusteredQueue(office1, 1, "sub1", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);
         bindings[0] = office1.bindClusteredQueue(new SimpleCondition("topic1"), queues[0]);
        
         queues[1] =
            new LocalClusteredQueue(office1, 1, "sub2", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);
         bindings[1] = office1.bindClusteredQueue(new SimpleCondition("topic1"), queues[1]);
        
         queues[2] =
            new LocalClusteredQueue(office2, 2, "sub3", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);
         bindings[2] = office2.bindClusteredQueue(new SimpleCondition("topic1"), queues[2]);
        
         queues[3] =
            new LocalClusteredQueue(office2, 2, "sub4", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);
         bindings[3] = office2.bindClusteredQueue(new SimpleCondition("topic1"), queues[3]);
        
         queues[4] =
            new LocalClusteredQueue(office2, 2, "sub5", channelIDManager.getID(), ms, pm,
                                    true, true, -1, null, tr);
         bindings[4] = office2.bindClusteredQueue(new SimpleCondition("topic1"), queues[4]);
        
         queues[5] =
            new LocalClusteredQueue(office1, 1, "sub6", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);
         bindings[5] = office1.bindClusteredQueue(new SimpleCondition("topic1"), queues[5]);
        
         queues[6] =
            new LocalClusteredQueue(office1, 1, "sub7", channelIDManager.getID(), ms, pm,
                                    true, true, -1, null, tr);
         bindings[6] = office1.bindClusteredQueue(new SimpleCondition("topic1"), queues[6]);
        
         queues[7] =
            new LocalClusteredQueue(office1, 1, "sub8", channelIDManager.getID(), ms, pm,
                                    true, true, -1, null, tr);
         bindings[7] = office1.bindClusteredQueue(new SimpleCondition("topic1"), queues[7]);
        
         queues[8] =
            new LocalClusteredQueue(office1, 1, "sub9", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);
         bindings[8] = office1.bindClusteredQueue(new SimpleCondition("topic2"), queues[8]);
        
         queues[9] =
            new LocalClusteredQueue(office1, 1, "sub10", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);
         bindings[9] = office1.bindClusteredQueue(new SimpleCondition("topic2"), queues[9]);
        
         queues[10] =
            new LocalClusteredQueue(office2, 2, "sub11", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);
         bindings[10] = office2.bindClusteredQueue(new SimpleCondition("topic2"), queues[10]);
        
         queues[11] =
            new LocalClusteredQueue(office2, 2, "sub12", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);
         bindings[11] = office2.bindClusteredQueue(new SimpleCondition("topic2"), queues[11]);
        
         queues[12] =
            new LocalClusteredQueue(office2, 2, "sub13", channelIDManager.getID(), ms, pm,
                                    true, true, -1, null, tr);
         bindings[12] = office2.bindClusteredQueue(new SimpleCondition("topic2"), queues[12]);
        
         queues[13] =
            new LocalClusteredQueue(office1, 1, "sub14", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);
         bindings[13] = office1.bindClusteredQueue(new SimpleCondition("topic2"), queues[13]);
        
         queues[14] =
            new LocalClusteredQueue(office1, 1, "sub15", channelIDManager.getID(), ms, pm,
                                    true, true, -1, null, tr);
         bindings[14] = office1.bindClusteredQueue(new SimpleCondition("topic2"), queues[14]);
        
         queues[15] =
            new LocalClusteredQueue(office1, 1, "sub16", channelIDManager.getID(), ms, pm,
                                    true, true, -1, null, tr);
         bindings[15] = office1.bindClusteredQueue(new SimpleCondition("topic2"), queues[15]);

         SimpleReceiver[] receivers = new SimpleReceiver[16];
        
         for (int i = 0; i < 16; i++)
         {
            receivers[i] = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
            queues[i].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("topic1"), tx);        
         assertTrue(routed);
         routed = office1.route(ref2, new SimpleCondition("topic1"), tx);        
         assertTrue(routed);

        
         for (int i = 0; i < 16; i++)
         {
            List msgs = receivers[i].getMessages();
            assertNotNull(msgs);
            assertTrue(msgs.isEmpty());
            msgs = queues[i].browse();
            assertNotNull(msgs);
            assertTrue(msgs.isEmpty());
         }
        
         tx.commit();
        
         //Messages are sent asych so may take some finite time to arrive
         Thread.sleep(1000);
        
         for (int i = 0; i < 8; 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();
            assertNotNull(msgs);           
            assertTrue(msgs.isEmpty());                       
            receivers[i].clear();
         }
        
         for (int i = 8; i < 16; i++)
         {
            List msgs = receivers[i].getMessages();
            assertNotNull(msgs);
            assertTrue(msgs.isEmpty());
            msgs = queues[i].browse();
            assertNotNull(msgs);
            assertTrue(msgs.isEmpty());
         }
        
         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("topic1"), tx);        
         assertTrue(routed);
         routed = office1.route(ref2, new SimpleCondition("topic1"), tx);        
         assertTrue(routed);
        
         //Messages are sent asych so may take some finite time to arrive
         Thread.sleep(1000);        
        
         for (int i = 0; i < 16; i++)
         {
            List msgs = receivers[i].getMessages();
            assertNotNull(msgs);
            assertTrue(msgs.isEmpty());
            msgs = queues[i].browse();
            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();
            assertNotNull(msgs);
            assertTrue(msgs.isEmpty());
         }
        
         //Now send some non transactionally
        
         msg1 = CoreMessageFactory.createCoreMessage(1, persistent, null);
         ref1 = ms.reference(msg1);
        
         msg2 = CoreMessageFactory.createCoreMessage(2, persistent, null);
         ref2 = ms.reference(msg2);
        
         routed = office1.route(ref1, new SimpleCondition("topic1"), null);        
         assertTrue(routed);
         routed = office1.route(ref2, new SimpleCondition("topic1"), null);        
         assertTrue(routed);
        
         //Messages are sent asych so may take some finite time to arrive
         Thread.sleep(1000);        
        
         //And acknowledge transactionally
        
         tx = tr.createTransaction();
        
         for (int i = 0; i < 8; 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, tx);
            receivers[i].acknowledge(msgRec2, tx);
            
            int deliveringCount = queues[i].getDeliveringCount();
           
            assertEquals(2, deliveringCount);
                      
            receivers[i].clear();
         }
        
         for (int i = 8; i < 16; i++)
         {
            List msgs = receivers[i].getMessages();
            assertNotNull(msgs);
            assertTrue(msgs.isEmpty());
            msgs = queues[i].browse();
            assertNotNull(msgs);
            assertTrue(msgs.isEmpty());
         }
        
         tx.commit();
        
         for (int i = 0; i < 16; i++)
         {
            List msgs = receivers[i].getMessages();
            assertNotNull(msgs);
            assertTrue(msgs.isEmpty());
            msgs = queues[i].browse();
            assertNotNull(msgs);
            assertTrue(msgs.isEmpty());
         }
        
        
         // and the rollback
        
         msg1 = CoreMessageFactory.createCoreMessage(1, persistent, null);;     
         ref1 = ms.reference(msg1);
        
         msg2 = CoreMessageFactory.createCoreMessage(2, persistent, null);;     
         ref2 = ms.reference(msg2);
        
         routed = office1.route(ref1, new SimpleCondition("topic1"), null);        
         assertTrue(routed);
         routed = office1.route(ref2, new SimpleCondition("topic1"), null);        
         assertTrue(routed);
        
         Thread.sleep(1000);
                
         tx = tr.createTransaction();
        
         for (int i = 0; i < 8; 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, tx);
            receivers[i].acknowledge(msgRec2, tx);
              
            int deliveringCount = queues[i].getDeliveringCount();
           
            assertEquals(2, deliveringCount);
           
         }
        
         for (int i = 8; i < 16; i++)
         {
            List msgs = receivers[i].getMessages();
            assertNotNull(msgs);
            assertTrue(msgs.isEmpty());
            msgs = queues[i].browse();
            assertNotNull(msgs);
            assertTrue(msgs.isEmpty());
         }
        
         tx.rollback();
        
         for (int i = 0; i < 8; 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());     
                                
            int deliveringCount = queues[i].getDeliveringCount();
           
            assertEquals(2, deliveringCount);
           
            receivers[i].acknowledge(msgRec1, null);
            receivers[i].acknowledge(msgRec2, null);
                          
            receivers[i].clear();
         }
        
         for (int i = 8; i < 16; i++)
         {
            List msgs = receivers[i].getMessages();
            assertNotNull(msgs);
            assertTrue(msgs.isEmpty());
            msgs = queues[i].browse();
            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 = office1.route(ref1, new SimpleCondition("topic2"), tx);        
         assertTrue(routed);
         routed = office1.route(ref2, new SimpleCondition("topic2"), tx);        
         assertTrue(routed);
        
        
        
         for (int i = 0; i < 16; i++)
         {
            List msgs = receivers[i].getMessages();
            assertNotNull(msgs);
            assertTrue(msgs.isEmpty());
            msgs = queues[i].browse();
            assertNotNull(msgs);
            assertTrue(msgs.isEmpty());
         }
        
         tx.commit();
        
         //Messages are sent asych so may take some finite time to arrive
         Thread.sleep(1000);
        
         for (int i = 0; i < 8; i++)
         {
            List msgs = receivers[i].getMessages();
            assertNotNull(msgs);
            assertTrue(msgs.isEmpty());
            msgs = queues[i].browse();
            assertNotNull(msgs);
            assertTrue(msgs.isEmpty());
         }
        
         for (int i = 8; i < 16; 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();
            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("topic1"), tx);        
         assertTrue(routed);
         routed = office1.route(ref2, new SimpleCondition("topic1"), tx);        
         assertTrue(routed);
        
         for (int i = 0; i < 16; i++)
         {
            List msgs = receivers[i].getMessages();
            assertNotNull(msgs);
            assertTrue(msgs.isEmpty());
            msgs = queues[i].browse();
            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();
            assertNotNull(msgs);
            assertTrue(msgs.isEmpty());
         }
        
         //Now send some non transactionally
        
         msg1 = CoreMessageFactory.createCoreMessage(1, persistent, null);     
         ref1 = ms.reference(msg1);
        
         msg2 = CoreMessageFactory.createCoreMessage(2, persistent, null);     
         ref2 = ms.reference(msg2);
        
         routed = office1.route(ref1, new SimpleCondition("topic2"), null);        
         assertTrue(routed);
         routed = office1.route(ref2, new SimpleCondition("topic2"), null);        
         assertTrue(routed);
        
         Thread.sleep(1000);
        
         //And acknowledge transactionally
        
         tx = tr.createTransaction();
        
         for (int i = 0; i < 8; i++)
         {
            List msgs = receivers[i].getMessages();
            assertNotNull(msgs);
            assertTrue(msgs.isEmpty());
            msgs = queues[i].browse();
            assertNotNull(msgs);
            assertTrue(msgs.isEmpty());
         }
        
         for (int i = 8; i < 16; 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, tx);
            receivers[i].acknowledge(msgRec2, tx);
                       
            int deliveringCount = queues[i].getDeliveringCount();
           
            assertEquals(2, deliveringCount);
           
            receivers[i].clear();
         }
        
        
        
         tx.commit();
        
         for (int i = 0; i < 16; i++)
         {
            List msgs = receivers[i].getMessages();
            assertNotNull(msgs);
            assertTrue(msgs.isEmpty());
            msgs = queues[i].browse();
            assertNotNull(msgs);
            assertTrue(msgs.isEmpty());
         }
        
        
         // and the rollback
        
         msg1 = CoreMessageFactory.createCoreMessage(1, persistent, null);;     
         ref1 = ms.reference(msg1);
        
         msg2 = CoreMessageFactory.createCoreMessage(2, persistent, null);;     
         ref2 = ms.reference(msg2);
        
         routed = office1.route(ref1, new SimpleCondition("topic2"), null);        
         assertTrue(routed);
         routed = office1.route(ref2, new SimpleCondition("topic2"), null);        
         assertTrue(routed);
        
         Thread.sleep(1000);
         
         tx = tr.createTransaction();
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

     
      try
      {     
         office = createNonClusteredPostOffice();
        
         Condition condition1 = new SimpleCondition("condition1");
        
         MessagingQueue queue1 = new MessagingQueue(1, "queue1", channelIDManager.getID(), ms, pm, false, -1, null, false);
         queue1.activate();
        
         office.addBinding(new Binding(condition1, queue1, false), false);
        
         MessagingQueue queue2 = new MessagingQueue(1, "queue2", channelIDManager.getID(), ms, pm, false, -1, null, false);
         queue2.activate();
        
         office.addBinding(new Binding(condition1, queue2, false), false);
        
         MessagingQueue queue3 = new MessagingQueue(1, "queue3", channelIDManager.getID(), ms, pm, false, -1, null, false);
         queue3.activate();
        
         office.addBinding(new Binding(condition1, queue3, false), false);
        
         MessagingQueue queue4 = new MessagingQueue(1, "queue4", channelIDManager.getID(), ms, pm, false, -1, null, false);
         queue4.activate();
        
         office.addBinding(new Binding(condition1, queue4, false), false);
        
         MessagingQueue queue5 = new MessagingQueue(1, "queue5", channelIDManager.getID(), ms, pm, false, -1, null, false);
         queue5.activate();
        
         Condition condition2 = new SimpleCondition("condition2");        
        
         office.addBinding(new Binding(condition2, queue5, false), false);
        
         MessagingQueue queue6 = new MessagingQueue(1, "queue6", channelIDManager.getID(), ms, pm, false, -1, null, false);
         queue6.activate();
        
         office.addBinding(new Binding(condition2, queue6, false), false);
        
         MessagingQueue queue7 = new MessagingQueue(1, "queue7", channelIDManager.getID(), ms, pm, false, -1, null, false);
         queue7.activate();
        
         office.addBinding(new Binding(condition2, queue7, false), false);
        
         MessagingQueue queue8 = new MessagingQueue(1, "queue8", channelIDManager.getID(), ms, pm,  false, -1, null, false);
         queue8.activate();
        
         office.addBinding(new Binding(condition2, queue8, false), false);
                 
         Collection queues = office.getQueuesForCondition(new SimpleCondition("dummy"), true);
         assertNotNull(queues);
         assertTrue(queues.isEmpty());
                          
         //We don't match on substrings
         queues = office.getQueuesForCondition(new SimpleCondition("condition123"), true);
         assertNotNull(queues);
         assertTrue(queues.isEmpty());
        
         //We don't currently support hierarchies
         queues = office.getQueuesForCondition(new SimpleCondition("condition1.subcondition"), true);
         assertNotNull(queues);
         assertTrue(queues.isEmpty());
        
         //Lookup the queues
        
         queues = office.getQueuesForCondition(condition1, true);
         assertNotNull(queues);
         assertEquals(4, queues.size());
        
         assertTrue(queues.contains(queue1));
         assertTrue(queues.contains(queue2));
         assertTrue(queues.contains(queue3));
         assertTrue(queues.contains(queue4));
        
         queues = office.getQueuesForCondition(condition2, true);
         assertNotNull(queues);
         assertEquals(4, queues.size());
        
         assertTrue(queues.contains(queue5));
         assertTrue(queues.contains(queue6));
         assertTrue(queues.contains(queue7));
         assertTrue(queues.contains(queue8));
        
         //Lookup should work on new instance too
        
         queues = office.getQueuesForCondition(new SimpleCondition("condition1"), true);
         assertNotNull(queues);
         assertEquals(4, queues.size());
        
         assertTrue(queues.contains(queue1));
         assertTrue(queues.contains(queue2));
         assertTrue(queues.contains(queue3));
         assertTrue(queues.contains(queue4));
        
         queues = office.getQueuesForCondition(new SimpleCondition("condition2"), true);
         assertNotNull(queues);
         assertEquals(4, queues.size());
        
         assertTrue(queues.contains(queue5));
         assertTrue(queues.contains(queue6));
View Full Code Here

     
      try
      {     
         office = createNonClusteredPostOffice();
                 
         Condition condition1 = new SimpleCondition("condition1")
        
         MessagingQueue queue1 = new MessagingQueue(1, "queue1", channelIDManager.getID(), ms, pm, false, -1, null, false);
         office.addBinding(new Binding(condition1, queue1, false), false);
                        
         MessagingQueue queue2 = new MessagingQueue(1, "queue2", channelIDManager.getID(), ms, pm, false, -1, null, false);
         office.addBinding(new Binding(condition1, queue2, false), false);
        
         Condition condition2 = new SimpleCondition("condition2")
                 
         MessagingQueue queue3 = new MessagingQueue(1, "queue3", channelIDManager.getID(), ms, pm, false, -1, null, false);
         office.addBinding(new Binding(condition2, queue3, false), false);
        
         Binding b1 = office.getBindingForQueueName("queue1");
View Full Code Here

     
      try
      {     
         office = createNonClusteredPostOffice();
                 
         Condition condition1 = new SimpleCondition("condition1")
        
         MessagingQueue queue1 = new MessagingQueue(1, "queue1", channelIDManager.getID(), ms, pm, false, -1, null, false);
         office.addBinding(new Binding(condition1, queue1, false), false);
                        
         MessagingQueue queue2 = new MessagingQueue(1, "queue2", channelIDManager.getID(), ms, pm, false, -1, null, false);
         office.addBinding(new Binding(condition1, queue2, false), false);
        
         Condition condition2 = new SimpleCondition("condition2")
                 
         MessagingQueue queue3 = new MessagingQueue(1, "queue3", channelIDManager.getID(), ms, pm, false, -1, null, false);
         office.addBinding(new Binding(condition2, queue3, false), false);
        
         Binding b1 = office.getBindingForChannelID(queue1.getChannelID());
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.