Examples of SimpleCondition


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

         office6 = createClusteredPostOffice(6, "testgroup", sc, ms, pm, tr);
        
         LocalClusteredQueue queue1 =
            new LocalClusteredQueue(office2, 2, "queue1", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);
         office2.bindClusteredQueue(new SimpleCondition("topic"), queue1);
         SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         queue1.add(receiver1);
        
         LocalClusteredQueue queue2 =
            new LocalClusteredQueue(office3, 3, "queue1", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);
         office3.bindClusteredQueue(new SimpleCondition("topic"), queue2);
         SimpleReceiver receiver2 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         queue2.add(receiver2);
        
         LocalClusteredQueue queue3 =
            new LocalClusteredQueue(office4, 4, "queue1", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);
         office4.bindClusteredQueue(new SimpleCondition("topic"), queue3);
         SimpleReceiver receiver3 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         queue3.add(receiver3);
        
         LocalClusteredQueue queue4 =
            new LocalClusteredQueue(office5, 5, "queue1", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);
         office5.bindClusteredQueue(new SimpleCondition("topic"), queue4);
         SimpleReceiver receiver4 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         queue4.add(receiver4);
        
         LocalClusteredQueue queue5 =
            new LocalClusteredQueue(office6, 6, "queue1", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);
         office6.bindClusteredQueue(new SimpleCondition("topic"), queue5);
         SimpleReceiver receiver5 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         queue5.add(receiver5);
              
         List msgs = sendMessages("topic", persistent, office1, 1, null);        
         checkContainsAndAcknowledge(msgs, receiver1, queue1);        
View Full Code Here

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

         office6 = createClusteredPostOffice(6, "testgroup", sc, ms, pm, tr);
        
         LocalClusteredQueue queue1 =
            new LocalClusteredQueue(office2, 2, "queue1", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);
         office2.bindClusteredQueue(new SimpleCondition("topic"), queue1);
         SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         queue1.add(receiver1);
        
         LocalClusteredQueue queue2 =
            new LocalClusteredQueue(office3, 3, "queue1", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);
         office3.bindClusteredQueue(new SimpleCondition("topic"), queue2);
         SimpleReceiver receiver2 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         queue2.add(receiver2);
        
         LocalClusteredQueue queue3 =
            new LocalClusteredQueue(office4, 4, "queue1", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);
         office4.bindClusteredQueue(new SimpleCondition("topic"), queue3);
         SimpleReceiver receiver3 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         queue3.add(receiver3);
        
         LocalClusteredQueue queue4 =
            new LocalClusteredQueue(office5, 5, "queue1", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);
         office5.bindClusteredQueue(new SimpleCondition("topic"), queue4);
         SimpleReceiver receiver4 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         queue4.add(receiver4);
        
         LocalClusteredQueue queue5 =
            new LocalClusteredQueue(office6, 6, "queue1", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);
         office6.bindClusteredQueue(new SimpleCondition("topic"), queue5);
         SimpleReceiver receiver5 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);
         queue5.add(receiver5);
              
         List msgs = sendMessages("topic", persistent, office2, 3, null);        
         checkContainsAndAcknowledge(msgs, receiver1, queue1);        
View Full Code Here

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

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

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

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

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

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

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

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

         // Add a third office
                 
         office3 = createClusteredPostOffice(3, "testgroup", sc, ms, pm, tr);
        
         // Maks sure it picks up the bindings
        
         bindings = office3.listAllBindingsForCondition(new SimpleCondition("topic1"));
         assertNotNull(bindings);
         assertEquals(2, bindings.size());
        
         iter = bindings.iterator();
         assertEquivalent(binding3, (Binding)iter.next());
         assertEquivalent(binding4, (Binding)iter.next());
        
         // Add another binding on node 3
                 
         LocalClusteredQueue queue5 =
            new LocalClusteredQueue(office3, 3, "sub5", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);
        
         Binding binding5 =
            office3.bindClusteredQueue(new SimpleCondition("topic1"), queue5);
        
         // Make sure all nodes pick it up
        
         bindings = office1.listAllBindingsForCondition(new SimpleCondition("topic1"));
         assertNotNull(bindings);
         assertEquals(3, bindings.size());
        
         iter = bindings.iterator();
         assertEquivalent(binding3, (Binding)iter.next());
         assertEquivalent(binding4, (Binding)iter.next());
         assertEquivalent(binding5, (Binding)iter.next());
        
         bindings = office2.listAllBindingsForCondition(new SimpleCondition("topic1"));
         assertNotNull(bindings);
         assertEquals(3, bindings.size());
        
         iter = bindings.iterator();
         assertEquivalent(binding3, (Binding)iter.next());
         assertEquivalent(binding4, (Binding)iter.next());
         assertEquivalent(binding5, (Binding)iter.next());
        
         bindings = office3.listAllBindingsForCondition(new SimpleCondition("topic1"));
         assertNotNull(bindings);
         assertEquals(3, bindings.size());
        
         iter = bindings.iterator();
         assertEquivalent(binding3, (Binding)iter.next());
         assertEquivalent(binding4, (Binding)iter.next());
         assertEquivalent(binding5, (Binding)iter.next());
        
         // Add a durable and a non durable binding on node 1
        
         LocalClusteredQueue queue6 =
            new LocalClusteredQueue(office1, 1, "sub6", channelIDManager.getID(), ms, pm,
                                    true, true, -1, null, tr);
        
         Binding binding6 =
            office1.bindClusteredQueue(new SimpleCondition("topic1"), queue6);
        
         LocalClusteredQueue queue7 =
            new LocalClusteredQueue(office1, 1, "sub7", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);
        
         Binding binding7 =
            office1.bindClusteredQueue(new SimpleCondition("topic1"), queue7);
        
         // Make sure all nodes pick them up
        
         bindings = office1.listAllBindingsForCondition(new SimpleCondition("topic1"));
         assertNotNull(bindings);
         assertEquals(5, bindings.size());
        
         iter = bindings.iterator();
         assertEquivalent(binding3, (Binding)iter.next());
         assertEquivalent(binding4, (Binding)iter.next());
         assertEquivalent(binding5, (Binding)iter.next());
         assertEquivalent(binding6, (Binding)iter.next());
         assertEquivalent(binding7, (Binding)iter.next());
        
         bindings = office2.listAllBindingsForCondition(new SimpleCondition("topic1"));
         assertNotNull(bindings);
         assertEquals(5, bindings.size());
        
         iter = bindings.iterator();
         assertEquivalent(binding3, (Binding)iter.next());
         assertEquivalent(binding4, (Binding)iter.next());
         assertEquivalent(binding5, (Binding)iter.next());
         assertEquivalent(binding6, (Binding)iter.next());
         assertEquivalent(binding7, (Binding)iter.next());
        
         bindings = office3.listAllBindingsForCondition(new SimpleCondition("topic1"));
         assertNotNull(bindings);
         assertEquals(5, bindings.size());
        
         iter = bindings.iterator();
         assertEquivalent(binding3, (Binding)iter.next());
         assertEquivalent(binding4, (Binding)iter.next());
         assertEquivalent(binding5, (Binding)iter.next());
         assertEquivalent(binding6, (Binding)iter.next());
         assertEquivalent(binding7, (Binding)iter.next());
              
         // Stop office 1
         office1.stop();
 
         // Need to sleep since it may take some time for the view changed request to reach the
         // members which causes the bindings to be removed.
        
         Thread.sleep(1000);
        
         // All it's non durable bindings should be removed from the other nodes.
         // Durable bindings should remain.
        
         bindings = office2.listAllBindingsForCondition(new SimpleCondition("topic1"));
         assertNotNull(bindings);
         assertEquals(4, bindings.size());
        
         iter = bindings.iterator();
         assertEquivalent(binding3, (Binding)iter.next());
         assertEquivalent(binding4, (Binding)iter.next());
         assertEquivalent(binding5, (Binding)iter.next());
         assertEquivalent(binding6, (Binding)iter.next());
        
         bindings = office3.listAllBindingsForCondition(new SimpleCondition("topic1"));
         assertNotNull(bindings);
         assertEquals(4, bindings.size());
        
         iter = bindings.iterator();
         assertEquivalent(binding3, (Binding)iter.next());
         assertEquivalent(binding4, (Binding)iter.next());
         assertEquivalent(binding5, (Binding)iter.next());
         assertEquivalent(binding6, (Binding)iter.next());
        
         // Stop office 2
         office2.stop();
        
         bindings = office3.listAllBindingsForCondition(new SimpleCondition("topic1"));
         assertNotNull(bindings);
         assertEquals(2, bindings.size());
        
         iter = bindings.iterator();
         assertEquivalent(binding5, (Binding)iter.next());
         assertEquivalent(binding6, (Binding)iter.next());
        
         // Restart office 1 and office 2
         office1 = createClusteredPostOffice(1, "testgroup", sc, ms, pm, tr);
        
         office2 = createClusteredPostOffice(2, "testgroup", sc, ms, pm, tr);
        
         bindings = office1.listAllBindingsForCondition(new SimpleCondition("topic1"));
         assertNotNull(bindings);
         assertEquals(2, bindings.size());
        
         iter = bindings.iterator();
         assertEquivalent(binding5, (Binding)iter.next());
         assertEquivalent(binding6, (Binding)iter.next());
        
         bindings = office2.listAllBindingsForCondition(new SimpleCondition("topic1"));
         assertNotNull(bindings);
         assertEquals(2, bindings.size());
        
         iter = bindings.iterator();
         assertEquivalent(binding5, (Binding)iter.next());
         assertEquivalent(binding6, (Binding)iter.next());
        
         bindings = office3.listAllBindingsForCondition(new SimpleCondition("topic1"));
         assertNotNull(bindings);
         assertEquals(2, bindings.size());
        
         iter = bindings.iterator();
         assertEquivalent(binding5, (Binding)iter.next());
         assertEquivalent(binding6, (Binding)iter.next());
        
         // Stop all offices
        
         office1.stop();
         office2.stop();
         office3.stop();
        
         // Start them all
         office1 = createClusteredPostOffice(1, "testgroup", sc, ms, pm, tr);
         office2 = createClusteredPostOffice(2, "testgroup", sc, ms, pm, tr);
         office3 = createClusteredPostOffice(3, "testgroup", sc, ms, pm, tr);
        
         // Only the durable queue should survive
        
         bindings = office1.listAllBindingsForCondition(new SimpleCondition("topic1"));
         assertNotNull(bindings);
         assertEquals(1, bindings.size());
        
         iter = bindings.iterator();
         assertEquivalent(binding6, (Binding)iter.next());
        
         bindings = office2.listAllBindingsForCondition(new SimpleCondition("topic1"));
         assertNotNull(bindings);
         assertEquals(1, bindings.size());
        
         iter = bindings.iterator();
         assertEquivalent(binding6, (Binding)iter.next());
        
         bindings = office3.listAllBindingsForCondition(new SimpleCondition("topic1"));
         assertNotNull(bindings);
         assertEquals(1, bindings.size());
        
         iter = bindings.iterator();
         assertEquivalent(binding6, (Binding)iter.next());
View Full Code Here

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

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

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

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

         LocalClusteredQueue queue3 =
            new LocalClusteredQueue(office1, 1, "queue1", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);
        
         try
         {
            office1.bindClusteredQueue(new SimpleCondition("queue1"), queue3);
            fail();
         }
         catch (Exception e)
         {
            //Ok
         }

         LocalClusteredQueue queue4 =
            new LocalClusteredQueue(office2, 2, "queue1", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);
        
         try
         {
            office2.bindClusteredQueue(new SimpleCondition("queue1"), queue4);
            fail();
         }
         catch (Exception e)
         {
            //Ok
         }
        
         office2.unbindClusteredQueue("queue1");

         office1.unbindClusteredQueue("queue1");

         LocalClusteredQueue queue5 =
            new LocalClusteredQueue(office1, 1, "queue1", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);
        
         office1.bindClusteredQueue(new SimpleCondition("queue1"), queue5);
        
         PagingFilteredQueue queue6 =
            new PagingFilteredQueue("queue1", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null);
         try
         {
            office1.bindQueue(new SimpleCondition("queue1"), queue6);
            fail();
         }
         catch (Exception e)
         {
            //ok
         }
         
         office1.unbindClusteredQueue("queue1");
        
         // It should be possible to bind queues locally into a clustered post office
         LocalClusteredQueue queue7 =
            new LocalClusteredQueue(office1, 1, "queue1", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);

         office1.bindQueue(new SimpleCondition("queue1"), queue7);
        
         LocalClusteredQueue queue8 =
            new LocalClusteredQueue(office2, 2, "queue1", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);

         office2.bindQueue(new SimpleCondition("queue1"), queue8);
        
         LocalClusteredQueue queue9 =
            new LocalClusteredQueue(office2, 2, "queue1", channelIDManager.getID(), ms, pm,
                                    true, false, -1, null, tr);

         try
         {
            office1.bindQueue(new SimpleCondition("queue1"), queue9);
            fail();
         }
         catch (Exception e)
         {
            //Ok
View Full Code Here

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

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

        
         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

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

        
         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

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

         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

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

         // 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

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

         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
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.