Package org.jboss.messaging.core.impl.postoffice

Examples of org.jboss.messaging.core.impl.postoffice.RouteResult


       //Route to condition1 from office1        

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

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

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

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

       checkNotGetsMessage(queue1, receiver1);

       checkNotGetsMessage(queue2, receiver2);

       checkNotGetsMessage(queue3, receiver3);

       //  Route to myqueue1 from office 2     

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

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

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

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

       checkNotGetsMessage(queue0, receiver0);

       checkNotGetsMessage(queue2, receiver2);

       checkNotGetsMessage(queue3, receiver3);


       //Now route to condition2 from office 1

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

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

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

       checkNotGetsMessage(queue1, receiver1);

       checkNotGetsMessage(queue0, receiver0);

       checkNotGetsMessage(queue3, receiver3);


       //Now route to condition2 from office 2

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

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

       // Only queue3 should get the message
       checkGetsMessage(queue3, receiver3, msg);
View Full Code Here


         assertTrue(queue4.isActive());     
        
         Message msg1 = CoreMessageFactory.createCoreMessage(1);     
         MessageReference ref1 = ms.reference(msg1);
        
         RouteResult routed = postOffice.route(ref1, condition1, null);     
         assertTrue(routed.getResult());
        
         List msgs = receiver1.getMessages();
         assertNotNull(msgs);
         assertTrue(msgs.isEmpty());
        
         msgs = receiver2.getMessages();
         assertNotNull(msgs);
         assertTrue(msgs.isEmpty());
        
         msgs = receiver3.getMessages();
         assertNotNull(msgs);
         assertEquals(1, msgs.size());
         Message msgRec = (Message)msgs.get(0);
         assertTrue(msg1 == msgRec);
         receiver3.acknowledge(msgRec, null);
         msgs = queue3.browse(null);
         assertNotNull(msgs);
         assertTrue(msgs.isEmpty())
        
         msgs = receiver4.getMessages();
         assertNotNull(msgs);
         assertTrue(msgs.isEmpty());
        
         msgs = receiver5.getMessages();
         assertNotNull(msgs);
         assertTrue(msgs.isEmpty());
        
         msgs = receiver6.getMessages();
         assertNotNull(msgs);
         assertTrue(msgs.isEmpty());
        
         receiver3.clear();
                    
         Message msg2 = CoreMessageFactory.createCoreMessage(2);     
         MessageReference ref2 = ms.reference(msg2);
        
         routed = postOffice.route(ref2, condition2, null);     
         assertTrue(routed.getResult());
        
         msgs = receiver1.getMessages();
         assertNotNull(msgs);
         assertTrue(msgs.isEmpty());
        
View Full Code Here

  
         Message msg1 = CoreMessageFactory.createCoreMessage(1);     
        
         MessageReference ref1 = ms.reference(msg1);
        
         RouteResult routed = postOffice.route(ref1, new SimpleCondition("this won't match anything"), null);
        
         assertFalse(routed.getResult());
              
         List msgs = receiver1.getMessages();
         assertNotNull(msgs);
         assertTrue(msgs.isEmpty())
      }
View Full Code Here

         queue3.getLocalDistributor().add(receiver3);
        
         Message msg1 = CoreMessageFactory.createCoreMessage(1);     
         MessageReference ref1 = ms.reference(msg1);
        
         RouteResult routed = postOffice.route(ref1, condition1, null);     
         assertTrue(routed.getResult());
        
         List msgs = receiver1.getMessages();
         assertNotNull(msgs);
         assertEquals(1, msgs.size());
        
         msgs = receiver2.getMessages();
         assertNotNull(msgs);
         assertEquals(1, msgs.size());
        
         msgs = receiver3.getMessages();
         assertNotNull(msgs);
         assertEquals(1, msgs.size());
        
         receiver1.clear();
         receiver2.clear();
         receiver3.clear();
        
         postOffice.addInactiveCondition(condition1);
        
         msg1 = CoreMessageFactory.createCoreMessage(1);     
         ref1 = ms.reference(msg1);
        
         try
         {
            postOffice.route(ref1, condition1, null);     
            fail("Didn't get expected exception");
         }
         catch (IllegalStateException e)
         {
            //ignore
         }
        
         //none received
         msgs = receiver1.getMessages();
         assertNotNull(msgs);
         assertTrue(msgs.isEmpty());
        
         msgs = receiver2.getMessages();
         assertNotNull(msgs);
         assertTrue(msgs.isEmpty());
        
         msgs = receiver3.getMessages();
         assertNotNull(msgs);
         assertTrue(msgs.isEmpty());

         postOffice.removeInactiveCondition(condition1);
        
         msg1 = CoreMessageFactory.createCoreMessage(1);     
         ref1 = ms.reference(msg1);

         //all received
         routed = postOffice.route(ref1, condition1, null);     
         assertTrue(routed.getResult());
        
         msgs = receiver1.getMessages();
         assertNotNull(msgs);
         assertEquals(1, msgs.size());
        
View Full Code Here

         queue2.setFailure(true);
        
         Message msg1 = CoreMessageFactory.createCoreMessage(1);
         MessageReference ref1 = ms.reference(msg1);
        
         RouteResult routed = postOffice.route(ref1, condition1, null);     
         assertTrue(routed.isFailue());
      }
      finally
      {
         if (postOffice != null)
         {
View Full Code Here

        }
      }
      else if (dest.isQueue())
      {
         if (trace) { log.trace(this + " routing " + msg + " to queue"); }
         RouteResult result = postOffice.route(ref, new JMSCondition(true, dest.getName()), tx);
         if (!result.getResult())
         {
            throw new JMSException("Failed to route " + ref + " to " + dest.getName());
         }
      }
      else
      {
         if (trace) { log.trace(this + " routing " + msg + " to postoffice"); }
         RouteResult result = postOffice.route(ref, new JMSCondition(false, dest.getName()), tx);
         if (result.isFailue())
         {
            throw new JMSException("Failed to route " + ref + " to " + dest.getName());
         }
      }
View Full Code Here

         MessageReference ref = ms.reference(msg);

         Condition condition = conditionFactory.createCondition(conditionText);

         RouteResult routed = office.route(ref, condition, null);

         assertTrue(routed.getResult());

         list.add(msg);
      }

      Thread.sleep(1000);
View Full Code Here

TOP

Related Classes of org.jboss.messaging.core.impl.postoffice.RouteResult

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.