Package org.jboss.jms.server.bridge

Examples of org.jboss.jms.server.bridge.Bridge$FailureHandler


      }                 
   }
  
   public void testDurableSubscriber() throws Exception
   {
      Bridge bridge = null;
           
      try
      {
         final int NUM_MESSAGES = 10;
        
         bridge = new Bridge(cff0, cff1, sourceTopicFactory, targetQueueFactory,
                  null, null, null, null,
                  null, 5000, 10, Bridge.QOS_AT_MOST_ONCE,
                  1, -1,
                  "subTest", "clientid123", false);
        
         bridge.start();
           
         sendMessages(cf0, sourceTopic, 0, NUM_MESSAGES, true);
        
         checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES);             
      }
      finally
      {                     
         if (bridge != null)
         {
            bridge.stop();
         }
        
         //Now unsubscribe
         Connection conn = cf0.createConnection();
         conn.setClientID("clientid123");
View Full Code Here


     messageIDInHeader(false);
   }
  
   private void messageIDInHeader(boolean on) throws Exception
   {
      Bridge bridge = null;
     
      Connection connSource = null;
     
      Connection connTarget = null;
           
      try
      {
         final int NUM_MESSAGES = 10;
        
         bridge = new Bridge(cff0, cff1, sourceQueueFactory, targetQueueFactory,
                  null, null, null, null,
                  null, 5000, 10, Bridge.QOS_AT_MOST_ONCE,
                  1, -1,
                  null, null, on);
        
         bridge.start();
        
         connSource = cf0.createConnection();
        
         connTarget = cf1.createConnection();
                   
         log.trace("Sending " + NUM_MESSAGES + " messages");
        
         List ids1 = new ArrayList();
    
         Session sessSource = connSource.createSession(false, Session.AUTO_ACKNOWLEDGE);
        
         MessageProducer prod = sessSource.createProducer(sourceQueue);
        
         for (int i = 0; i < NUM_MESSAGES; i++)
         {
            TextMessage tm = sessSource.createTextMessage("message" + i);
           
            //We add some headers to make sure they get passed through ok
            tm.setStringProperty("wib", "uhuh");
            tm.setBooleanProperty("cheese", true);
            tm.setIntProperty("Sausages", 23);
           
            //We add some JMSX ones too
           
            tm.setStringProperty("JMSXGroupID", "mygroup543");
            tm.setIntProperty("JMSXGroupSeq", 777);
           
            prod.send(tm);
           
            ids1.add(tm.getJMSMessageID());
         }

         log.trace("Sent the first messages");
        
         Session sessTarget = connTarget.createSession(false, Session.AUTO_ACKNOWLEDGE);
        
         MessageConsumer cons = sessTarget.createConsumer(targetQueue);
        
         connTarget.start();
        
         List msgs = new ArrayList();
        
         for (int i = 0; i < NUM_MESSAGES; i++)
         {
            TextMessage tm = (TextMessage)cons.receive(5000);
           
            assertNotNull(tm);
           
            assertEquals("message" + i, tm.getText());
           
            assertEquals("uhuh", tm.getStringProperty("wib"));
            assertTrue(tm.getBooleanProperty("cheese"));
            assertEquals(23, tm.getIntProperty("Sausages"));
           
            assertEquals("mygroup543", tm.getStringProperty("JMSXGroupID"));
            assertEquals(777, tm.getIntProperty("JMSXGroupSeq"));
           
            if (on)
            {           
              String header = tm.getStringProperty(JBossMessage.JBOSS_MESSAGING_BRIDGE_MESSAGE_ID_LIST);
             
              assertNotNull(header);
             
              assertEquals(ids1.get(i), header);
             
              msgs.add(tm);
            }
         }
        
         if (on)
         {          
           //Now we send them again back to the source
          
           Iterator iter = msgs.iterator();
          
           List ids2 = new ArrayList();
          
           while (iter.hasNext())
           {
             Message msg = (Message)iter.next();
            
             prod.send(msg);
             
              ids2.add(msg.getJMSMessageID());
           }
                                
           //And consume them again
          
           for (int i = 0; i < NUM_MESSAGES; i++)
           {
              TextMessage tm = (TextMessage)cons.receive(5000);
             
              assertNotNull(tm);
             
              assertEquals("message" + i, tm.getText());
             
              assertEquals("uhuh", tm.getStringProperty("wib"));
              assertTrue(tm.getBooleanProperty("cheese"));
              assertEquals(23, tm.getIntProperty("Sausages"));
             
              assertEquals("mygroup543", tm.getStringProperty("JMSXGroupID"));
              assertEquals(777, tm.getIntProperty("JMSXGroupSeq"));           
             
              String header = tm.getStringProperty(JBossMessage.JBOSS_MESSAGING_BRIDGE_MESSAGE_ID_LIST);
             
              assertNotNull(header);
             
              assertEquals(ids1.get(i) + "," + ids2.get(i), header);
           }
         }
        
      }
      finally
      {                       
         if (bridge != null)
         {
            bridge.stop();
         }
        
         if (connSource != null)
         {
            connSource.close();
View Full Code Here

     propertiesPreserved(true, true);
   }
  
   private void propertiesPreserved(boolean persistent, boolean messageIDInHeader) throws Exception
   {
      Bridge bridge = null;
     
      Connection connSource = null;
     
      Connection connTarget = null;
           
      try
      {
         final int NUM_MESSAGES = 10;
        
         bridge = new Bridge(cff0, cff1, sourceQueueFactory, targetQueueFactory,
                  null, null, null, null,
                  null, 5000, 10, Bridge.QOS_AT_MOST_ONCE,
                  1, -1,
                  null, null, messageIDInHeader);
        
         bridge.start();
        
         connSource = cf0.createConnection();
        
         connTarget = cf1.createConnection();
                   
         log.trace("Sending " + NUM_MESSAGES + " messages");
        
         Session sessSource = connSource.createSession(false, Session.AUTO_ACKNOWLEDGE);
        
         Session sessTarget = connTarget.createSession(false, Session.AUTO_ACKNOWLEDGE);
        
         MessageConsumer cons = sessTarget.createConsumer(targetQueue);
        
         connTarget.start();
        
         MessageProducer prod = sessSource.createProducer(sourceQueue);
        
         prod.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT)
        
        
        
         TextMessage tm = sessSource.createTextMessage("blahmessage");
        
         prod.setPriority(7);
        
         prod.setTimeToLive(1 * 60 * 60 * 1000);

         prod.send(tm);
        
         long expiration = tm.getJMSExpiration();
        
         assertEquals(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT, tm.getJMSDeliveryMode());
                                
         tm = (TextMessage)cons.receive(1000);
        
         assertNotNull(tm);
        
         assertEquals("blahmessage", tm.getText());

         assertEquals(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT, tm.getJMSDeliveryMode());
        
         assertEquals(7, tm.getJMSPriority());
       
         assertTrue(Math.abs(expiration - tm.getJMSExpiration()) < 100);
                 
         Message m = cons.receive(5000);
        
         assertNull(m);
        
        
         //Now do one with expiration = 0
        
        
         tm = sessSource.createTextMessage("blahmessage2");
        
         prod.setPriority(7);
        
         prod.setTimeToLive(0);

         prod.send(tm);
        
         assertEquals(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT, tm.getJMSDeliveryMode());
                                
         tm = (TextMessage)cons.receive(1000);
        
         assertNotNull(tm);
        
         assertEquals("blahmessage2", tm.getText());

         assertEquals(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT, tm.getJMSDeliveryMode());
        
         assertEquals(7, tm.getJMSPriority());
       
         assertEquals(0, tm.getJMSExpiration());
                 
         m = cons.receive(5000);
        
         assertNull(m);
        
         tm = sessSource.createTextMessage("blahmessage3");

         final boolean myBool = false;
         final byte myByte = (byte)23;
         final double myDouble = 17625765d;
         final float myFloat = 87127.23f;
         final int myInt = 123;
         final long myLong = 81728712;
         final short myShort = (short)88;
         final String myString = "ojweodewj";
         final String myJMSX = "aardvark";

         tm.setBooleanProperty("mybool", myBool);
         tm.setByteProperty("mybyte", myByte);
         tm.setDoubleProperty("mydouble", myDouble);
         tm.setFloatProperty("myfloat", myFloat);
         tm.setIntProperty("myint", myInt);
         tm.setLongProperty("mylong", myLong);
         tm.setShortProperty("myshort", myShort);
         tm.setStringProperty("mystring", myString);

         tm.setStringProperty("JMSXMyNaughtyJMSXProperty", myJMSX);

         prod.send(tm);

         tm = (TextMessage)cons.receive(1000);

         assertNotNull(tm);

         assertEquals("blahmessage3", tm.getText());

         assertEquals(myBool, tm.getBooleanProperty("mybool"));
         assertEquals(myByte, tm.getByteProperty("mybyte"));
         assertEquals(myDouble, tm.getDoubleProperty("mydouble"));
         assertEquals(myFloat, tm.getFloatProperty("myfloat"));
         assertEquals(myInt, tm.getIntProperty("myint"));
         assertEquals(myLong, tm.getLongProperty("mylong"));
         assertEquals(myShort, tm.getShortProperty("myshort"));
         assertEquals(myString, tm.getStringProperty("mystring"));
         assertEquals(myJMSX, tm.getStringProperty("JMSXMyNaughtyJMSXProperty"));

         m = cons.receive(5000);
        
      }
      finally
      {                       
         if (bridge != null)
         {
            bridge.stop();
         }
        
         if (connSource != null)
         {
            connSource.close();
View Full Code Here

      }                 
   }
  
   public void testNoMessageIDInHeader() throws Exception
   {
      Bridge bridge = null;
     
      Connection connSource = null;
     
      Connection connTarget = null;
           
      try
      {
         final int NUM_MESSAGES = 10;
        
         bridge = new Bridge(cff0, cff1, sourceQueueFactory, targetQueueFactory,
                  null, null, null, null,
                  null, 5000, 10, Bridge.QOS_AT_MOST_ONCE,
                  1, -1,
                  null, null, false);
        
         bridge.start();
        
         connSource = cf0.createConnection();
        
         connTarget = cf1.createConnection();
                   
         log.trace("Sending " + NUM_MESSAGES + " messages");
        
         Session sessSource = connSource.createSession(false, Session.AUTO_ACKNOWLEDGE);
        
         MessageProducer prod = sessSource.createProducer(sourceQueue);
        
         for (int i = 0; i < NUM_MESSAGES; i++)
         {
            TextMessage tm = sessSource.createTextMessage("message" + i);
           
            //We add some headers to make sure they get passed through ok
            tm.setStringProperty("wib", "uhuh");
            tm.setBooleanProperty("cheese", true);
            tm.setIntProperty("Sausages", 23);
           
            prod.send(tm);
         }

         log.trace("Sent the first messages");
        
         Session sessTarget = connTarget.createSession(false, Session.AUTO_ACKNOWLEDGE);
        
         MessageConsumer cons = sessTarget.createConsumer(targetQueue);
        
         connTarget.start();
        
         for (int i = 0; i < NUM_MESSAGES; i++)
         {
            TextMessage tm = (TextMessage)cons.receive(5000);
           
            assertNotNull(tm);
           
            assertEquals("message" + i, tm.getText());
           
            assertEquals("uhuh", tm.getStringProperty("wib"));
            assertTrue(tm.getBooleanProperty("cheese"));
            assertEquals(23, tm.getIntProperty("Sausages"));
           
            String header = tm.getStringProperty(JBossMessage.JBOSS_MESSAGING_BRIDGE_MESSAGE_ID_LIST);
           
            assertNull(header);
         }                
      }
      finally
      {                       
         if (bridge != null)
         {
            bridge.stop();
         }
        
         if (connSource != null)
         {
            connSource.close();
View Full Code Here

            
   private void testStress(int qosMode, boolean persistent, int batchSize) throws Exception
   {
      Connection connSource = null;
     
      Bridge bridge = null;
     
      Thread t = null;
           
      try
      {     
         bridge = new Bridge(cff0, cff1, sourceQueueFactory, targetQueueFactory,
                  null, null, null, null,
                  null, 5000, 10, qosMode,
                  batchSize, -1,
                  null, null, false);
        
         bridge.start();
           
         connSource = cf0.createConnection();
        
         Session sessSend = connSource.createSession(false, Session.AUTO_ACKNOWLEDGE);
        
         MessageProducer prod = sessSend.createProducer(sourceQueue);
        
         final int NUM_MESSAGES = 250;
        
         StressSender sender = new StressSender();
         sender.sess = sessSend;
         sender.prod = prod;
         sender.numMessages = NUM_MESSAGES;
         prod.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
                         
         t = new Thread(sender);
        
         t.start();
        
         this.checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES);
                                             
         t.join();
        
         if (sender.ex != null)
         {
            //An error occurred during the send
            throw sender.ex;
         }
          
      }
      finally
      {   
         if (t != null)
         {
            t.join(10000);
         }
        
         if (connSource != null)
         {
            try
            {
               connSource.close();
            }
            catch (Exception e)
            {
               log.error("Failed to close connection", e);
            }
         }               
        
         if (bridge != null)
         {
            bridge.stop();
         }                 
      }     
   }
View Full Code Here

  
   private void testStressBatchTime(int qosMode, boolean persistent, int maxBatchTime) throws Exception
   {
      Connection connSource = null;
     
      Bridge bridge = null;
     
      Thread t = null;
           
      try
      {     
         bridge = new Bridge(cff0, cff1, sourceQueueFactory, targetQueueFactory,
                  null, null, null, null,
                  null, 5000, 10, qosMode,
                  2, maxBatchTime,
                  null, null, false);
        
         bridge.start();
           
         connSource = cf0.createConnection();
        
         Session sessSend = connSource.createSession(false, Session.AUTO_ACKNOWLEDGE);
        
         MessageProducer prod = sessSend.createProducer(sourceQueue);
        
         final int NUM_MESSAGES = 5000;
        
         StressSender sender = new StressSender();
         sender.sess = sessSend;
         sender.prod = prod;
         sender.numMessages = NUM_MESSAGES;
         prod.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
                         
         t = new Thread(sender);
        
         t.start();
        
         this.checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES);
                                             
         t.join();
        
         if (sender.ex != null)
         {
            //An error occurred during the send
            throw sender.ex;
         }
          
      }
      finally
      {   
         if (t != null)
         {
            t.join(10000);
         }
        
         if (connSource != null)
         {
            try
            {
               connSource.close();
            }
            catch (Exception e)
            {
               log.error("Failed to close connection", e);
            }
         }               
        
         if (bridge != null)
         {
            bridge.stop();
         }                 
      }     
   }
View Full Code Here

   //Both source and destination on same rm
   private void testStressSameServer(int qosMode, boolean persistent, int batchSize) throws Exception
   {
      Connection connSource = null;
     
      Bridge bridge = null;
     
      Thread t = null;
           
      try
     
         bridge = new Bridge(cff0, cff0, sourceQueueFactory, localTargetQueueFactory,
                  null, null, null, null,
                  null, 5000, 10, qosMode,
                  batchSize, -1,
                  null, null, false);
        
         bridge.start();
           
         connSource = cf0.createConnection();
        
         Session sessSend = connSource.createSession(false, Session.AUTO_ACKNOWLEDGE);
        
         MessageProducer prod = sessSend.createProducer(sourceQueue);
        
         final int NUM_MESSAGES = 2000;
        
         StressSender sender = new StressSender();
         sender.sess = sessSend;
         sender.prod = prod;
         sender.numMessages = NUM_MESSAGES;
         prod.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
                         
         t = new Thread(sender);
        
         t.start();
        
         this.checkAllMessageReceivedInOrder(cf0, localTargetQueue, 0, NUM_MESSAGES);
                        
         t.join();
        
         if (sender.ex != null)
         {
            //An error occurred during the send
            throw sender.ex;
         }
          
      }
      finally
      {   
         if (t != null)
         {
            t.join(10000);
         }
        
         if (connSource != null)
         {
            try
            {
               connSource.close();
            }
            catch (Exception e)
            {
               log.error("Failed to close connection", e);
            }
         }
                         
         if (bridge != null)
         {
            bridge.stop();
         }
      }     
   }
View Full Code Here

   }
  
     
   private void testNoMaxBatchTime(int qosMode, boolean persistent) throws Exception
   {
      Bridge bridge = null;
           
      try
      {
         final int NUM_MESSAGES = 10;
        
         bridge = new Bridge(cff0, cff1, sourceQueueFactory, targetQueueFactory,
                  null, null, null, null,
                  null, 5000, 10, qosMode,
                  NUM_MESSAGES, -1,
                  null, null, false);
        
         bridge.start();
           
         //Send half the messges

         this.sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES / 2, persistent);
                        
         //Verify none are received
        
         this.checkEmpty(targetQueue, 1);
        
         //Send the other half
        
         this.sendMessages(cf0, sourceQueue, NUM_MESSAGES / 2, NUM_MESSAGES / 2, persistent);
        
         //This should now be receivable
        
         this.checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES);
        
         //Send another batch with one more than batch size
        
         this.sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES + 1, persistent);
                 
         //Make sure only batch size are received
        
         this.checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES);
        
         //Final batch
        
         this.sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES - 1, persistent);
        
         this.checkAllMessageReceivedInOrder(cf1, targetQueue, NUM_MESSAGES, 1);
        
         this.checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES - 1);
      }
      finally
      {     
         if (bridge != null)
         {
            log.info("Stopping bridge");
            bridge.stop();
         }        
      }                 
   }
View Full Code Here

      }                 
   }
  
   private void testNoMaxBatchTimeSameServer(int qosMode, boolean persistent) throws Exception
   {
      Bridge bridge = null;
           
      try
      {
         final int NUM_MESSAGES = 10;
        
         bridge = new Bridge(cff0, cff0, sourceQueueFactory, localTargetQueueFactory,
                  null, null, null, null,
                  null, 5000, 10, qosMode,
                  NUM_MESSAGES, -1,
                  null, null, false);
        
         bridge.start();
           
         this.sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES / 2, persistent);
        
         this.checkEmpty(targetQueue, 1);               
        
         //Send the other half
        
         this.sendMessages(cf0, sourceQueue, NUM_MESSAGES / 2, NUM_MESSAGES /2, persistent);
        
        
         //This should now be receivable
        
         this.checkAllMessageReceivedInOrder(cf0, localTargetQueue, 0, NUM_MESSAGES);
        
         this.checkEmpty(localTargetQueue, 0);
        
         this.checkEmpty(sourceQueue, 0);
        
         //Send another batch with one more than batch size
        
         this.sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES + 1, persistent);
        
         //Make sure only batch size are received
        
         this.checkAllMessageReceivedInOrder(cf0, localTargetQueue, 0, NUM_MESSAGES);
        
         //Final batch
        
         this.sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES - 1, persistent);
        
         this.checkAllMessageReceivedInOrder(cf0, localTargetQueue, NUM_MESSAGES, 1);
        
         this.checkAllMessageReceivedInOrder(cf0, localTargetQueue, 0, NUM_MESSAGES - 1);
      }
      finally
      {              
         if (bridge != null)
         {
            bridge.stop();
         }                 
      }                 
   }
View Full Code Here

      }                 
   }
  
   private void testMaxBatchTime(int qosMode, boolean persistent) throws Exception
   {
      Bridge bridge = null;
           
      try
      {
         final long MAX_BATCH_TIME = 3000;
        
         final int MAX_BATCH_SIZE = 100000; // something big so it won't reach it
        
         bridge = new Bridge(cff0, cff1, sourceQueueFactory, targetQueueFactory,
                  null, null, null, null,
                  null, 3000, 10, qosMode,
                  MAX_BATCH_SIZE, MAX_BATCH_TIME,
                  null, null, false);
        
         bridge.start();
           
         final int NUM_MESSAGES = 10;
        
         //Send some message

         this.sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES, persistent);                
        
         //Verify none are received
        
         this.checkEmpty(targetQueue, 1);
        
         //Messages should now be receivable
        
         this.checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES);        
      }
      finally
      {     
         if (bridge != null)
         {
            bridge.stop();
         }        
      }                 
   }
View Full Code Here

TOP

Related Classes of org.jboss.jms.server.bridge.Bridge$FailureHandler

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.