Package org.hornetq.jms.bridge.impl

Examples of org.hornetq.jms.bridge.impl.JMSBridgeImpl


      }
   }

   private void testMaxBatchTime(final QualityOfServiceMode qosMode, final boolean persistent) throws Exception
   {
      JMSBridgeImpl bridge = null;

      ConnectionFactoryFactory factInUse0 = cff0;
      ConnectionFactoryFactory factInUse1 = cff1;
      if (qosMode.equals(QualityOfServiceMode.ONCE_AND_ONLY_ONCE))
      {
         factInUse0 = cff0xa;
         factInUse1 = cff1xa;
      }

      try
      {
         final long MAX_BATCH_TIME = 3000;

         final int MAX_BATCH_SIZE = 100000; // something big so it won't reach it

         bridge = new JMSBridgeImpl(factInUse0,
                                    factInUse1,
                                    sourceQueueFactory,
                                    targetQueueFactory,
                                    null,
                                    null,
                                    null,
                                    null,
                                    null,
                                    3000,
                                    10,
                                    qosMode,
                                    MAX_BATCH_SIZE,
                                    MAX_BATCH_TIME,
                                    null,
                                    null,
                                    false);
         bridge.setTransactionManager(newTransactionManager());

         bridge.start();

         final int NUM_MESSAGES = 10;

         // Send some message

         sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES, persistent, false);

         // Verify none are received

         checkEmpty(targetQueue, 1);

         // Messages should now be receivable

         checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES, false);
      }
      finally
      {
         if (bridge != null)
         {
            bridge.stop();
         }
      }
   }
View Full Code Here


      }
   }

   private void testMaxBatchTimeSameServer(final QualityOfServiceMode qosMode, final boolean persistent) throws Exception
   {
      JMSBridgeImpl bridge = null;

      ConnectionFactoryFactory factInUse0 = cff0;
      if (qosMode.equals(QualityOfServiceMode.ONCE_AND_ONLY_ONCE))
      {
         factInUse0 = cff0xa;
      }

      try
      {
         final long MAX_BATCH_TIME = 3000;

         final int MAX_BATCH_SIZE = 100000; // something big so it won't reach it

         bridge = new JMSBridgeImpl(factInUse0,
                                    factInUse0,
                                    sourceQueueFactory,
                                    localTargetQueueFactory,
                                    null,
                                    null,
                                    null,
                                    null,
                                    null,
                                    3000,
                                    10,
                                    qosMode,
                                    MAX_BATCH_SIZE,
                                    MAX_BATCH_TIME,
                                    null,
                                    null,
                                    false);
         bridge.setTransactionManager(newTransactionManager());

         bridge.start();

         final int NUM_MESSAGES = 10;

         // Send some message

         // Send some message

         sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES, persistent, false);

         // Verify none are received

         checkEmpty(localTargetQueue, 0);;

         // Messages should now be receivable

         checkAllMessageReceivedInOrder(cf0, localTargetQueue, 0, NUM_MESSAGES, false);
      }
      finally
      {
         if (bridge != null)
         {
            bridge.stop();
         }
      }
   }
View Full Code Here

      }
   }

   public void testSetTMClass() throws Exception
   {
      JMSBridgeImpl bridge = null;

      try
      {
         bridge = new JMSBridgeImpl(cff0,
                                    cff0,
                                    sourceQueueFactory,
                                    localTargetQueueFactory,
                                    null,
                                    null,
                                    null,
                                    null,
                                    null,
                                    3000,
                                    10,
                                    QualityOfServiceMode.AT_MOST_ONCE,
                                    10000,
                                    3000,
                                    null,
                                    null,
                                    false);
         bridge.setTransactionManagerLocatorClass(this.getClass().getName());
         bridge.setTransactionManagerLocatorMethod("getNewTm");
         bridge.start();
      }
      finally
      {
         if (bridge != null)
         {
            bridge.stop();
         }
      }
   }
View Full Code Here

   {

      MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
      ObjectName objectName = new ObjectName("example.jmsbridge:service=JMSBridge");

      JMSBridgeImpl bridge = new JMSBridgeImpl(cff0,
                                               cff0,
                                               sourceQueueFactory,
                                               localTargetQueueFactory,
                                               null,
                                               null,
                                               null,
                                               null,
                                               null,
                                               5000,
                                               10,
                                               QualityOfServiceMode.AT_MOST_ONCE,
                                               1,
                                               -1,
                                               null,
                                               null,
                                               false,
                                               mbeanServer,
                                               objectName.getCanonicalName());

      Assert.assertTrue(mbeanServer.isRegistered(objectName));

      bridge.destroy();

      Assert.assertFalse(mbeanServer.isRegistered(objectName));
   }
View Full Code Here

      testStressSameServer(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, false, 1);
   }

   public void testParams() throws Exception
   {
      JMSBridgeImpl bridge = null;

      try
      {
         QualityOfServiceMode qosMode = QualityOfServiceMode.AT_MOST_ONCE;

         int batchSize = 10;

         int maxBatchTime = -1;

         String sourceUsername = null;

         String sourcePassword = null;

         String destUsername = null;

         String destPassword = null;

         String selector = null;

         long failureRetryInterval = 5000;

         int maxRetries = 10;

         String subName = null;

         String clientID = null;

         try
         {
            bridge = new JMSBridgeImpl(null,
                                       cff1,
                                       sourceQueueFactory,
                                       targetQueueFactory,
                                       sourceUsername,
                                       sourcePassword,
                                       destUsername,
                                       destPassword,
                                       selector,
                                       failureRetryInterval,
                                       maxRetries,
                                       qosMode,
                                       batchSize,
                                       maxBatchTime,
                                       subName,
                                       clientID,
                                       false);
         }
         catch (IllegalArgumentException e)
         {
            // Ok
         }

         try
         {
            bridge = new JMSBridgeImpl(cff0,
                                       null,
                                       sourceQueueFactory,
                                       targetQueueFactory,
                                       sourceUsername,
                                       sourcePassword,
                                       destUsername,
                                       destPassword,
                                       selector,
                                       failureRetryInterval,
                                       maxRetries,
                                       qosMode,
                                       batchSize,
                                       maxBatchTime,
                                       subName,
                                       clientID,
                                       false);
         }
         catch (IllegalArgumentException e)
         {
            // Ok
         }

         try
         {
            bridge = new JMSBridgeImpl(cff0,
                                       cff1,
                                       null,
                                       targetQueueFactory,
                                       sourceUsername,
                                       sourcePassword,
                                       destUsername,
                                       destPassword,
                                       selector,
                                       failureRetryInterval,
                                       maxRetries,
                                       qosMode,
                                       batchSize,
                                       maxBatchTime,
                                       subName,
                                       clientID,
                                       false);
         }
         catch (IllegalArgumentException e)
         {
            // Ok
         }

         try
         {
            bridge = new JMSBridgeImpl(cff0,
                                       cff1,
                                       sourceQueueFactory,
                                       null,
                                       sourceUsername,
                                       sourcePassword,
                                       destUsername,
                                       destPassword,
                                       selector,
                                       failureRetryInterval,
                                       maxRetries,
                                       qosMode,
                                       batchSize,
                                       maxBatchTime,
                                       subName,
                                       clientID,
                                       false);
         }
         catch (IllegalArgumentException e)
         {
            // Ok
         }

         try
         {
            bridge = new JMSBridgeImpl(cff0,
                                       cff1,
                                       sourceQueueFactory,
                                       targetQueueFactory,
                                       sourceUsername,
                                       sourcePassword,
                                       destUsername,
                                       destPassword,
                                       selector,
                                       -2,
                                       maxRetries,
                                       qosMode,
                                       batchSize,
                                       maxBatchTime,
                                       subName,
                                       clientID,
                                       false);
         }
         catch (IllegalArgumentException e)
         {
            // Ok
         }

         try
         {
            bridge = new JMSBridgeImpl(cff0,
                                       cff1,
                                       sourceQueueFactory,
                                       targetQueueFactory,
                                       sourceUsername,
                                       sourcePassword,
                                       destUsername,
                                       destPassword,
                                       selector,
                                       -1,
                                       10,
                                       qosMode,
                                       batchSize,
                                       maxBatchTime,
                                       subName,
                                       clientID,
                                       false);
         }
         catch (IllegalArgumentException e)
         {
            // Ok
         }

         try
         {
            bridge = new JMSBridgeImpl(cff0,
                                       cff1,
                                       sourceQueueFactory,
                                       null,
                                       sourceUsername,
                                       sourcePassword,
                                       destUsername,
                                       destPassword,
                                       selector,
                                       failureRetryInterval,
                                       maxRetries,
                                       qosMode,
                                       0,
                                       maxBatchTime,
                                       subName,
                                       clientID,
                                       false);
         }
         catch (IllegalArgumentException e)
         {
            // Ok
         }

         try
         {
            bridge = new JMSBridgeImpl(cff0,
                                       cff1,
                                       sourceQueueFactory,
                                       null,
                                       sourceUsername,
                                       sourcePassword,
                                       destUsername,
                                       destPassword,
                                       selector,
                                       failureRetryInterval,
                                       maxRetries,
                                       qosMode,
                                       batchSize,
                                       -2,
                                       subName,
                                       clientID,
                                       false);
         }
         catch (IllegalArgumentException e)
         {
            // Ok
         }
      }
      finally
      {
         if (bridge != null)
         {
            bridge.stop();
         }
      }
   }
View Full Code Here

      }
   }

   public void testStartStopStart() throws Exception
   {
      JMSBridgeImpl bridge = null;

      Connection connSource = null;

      Connection connTarget = null;

      try
      {
         final int NUM_MESSAGES = 10;

         bridge = new JMSBridgeImpl(cff0,
                                    cff1,
                                    sourceQueueFactory,
                                    targetQueueFactory,
                                    null,
                                    null,
                                    null,
                                    null,
                                    null,
                                    5000,
                                    10,
                                    QualityOfServiceMode.AT_MOST_ONCE,
                                    1,
                                    -1,
                                    null,
                                    null,
                                    false);
         bridge.setTransactionManager(newTransactionManager());

         bridge.start();

         bridge.stop();
        
         bridge.start();
        
         connSource = cf0.createConnection();

         Session sessSend = connSource.createSession(false, Session.AUTO_ACKNOWLEDGE);

         MessageProducer prod = sessSend.createProducer(sourceQueue);

         for (int i = 0; i < NUM_MESSAGES; i++)
         {
            TextMessage tm = sessSend.createTextMessage("message" + i);
            prod.send(tm);
         }

         connTarget = cf1.createConnection();
         Session sessRec = connTarget.createSession(false, Session.AUTO_ACKNOWLEDGE);
         MessageConsumer cons = sessRec.createConsumer(targetQueue);

         connTarget.start();

         for (int i = 0; i < NUM_MESSAGES; i++)
         {
            TextMessage tm = (TextMessage)cons.receive(10000);
            Assert.assertNotNull(tm);
            Assert.assertEquals("message" + i, tm.getText());
         }

         Message m = cons.receiveNoWait();
         Assert.assertNull(m);
      }
      finally
      {
         if (connSource != null)
         {
            connSource.close();
         }

         if (connTarget != null)
         {
            connTarget.close();
         }

         if (bridge != null)
         {
            bridge.stop();
         }

         removeAllMessages(sourceQueue.getQueueName(), 0);
      }
   }
View Full Code Here

      }
   }
  
   public void testSelector() throws Exception
   {
      JMSBridgeImpl bridge = null;

      Connection connSource = null;

      Connection connTarget = null;

      try
      {
         final int NUM_MESSAGES = 10;

         String selector = "vegetable='radish'";

         bridge = new JMSBridgeImpl(cff0,
                                    cff1,
                                    sourceQueueFactory,
                                    targetQueueFactory,
                                    null,
                                    null,
                                    null,
                                    null,
                                    selector,
                                    5000,
                                    10,
                                    QualityOfServiceMode.AT_MOST_ONCE,
                                    1,
                                    -1,
                                    null,
                                    null,
                                    false);
         bridge.setTransactionManager(newTransactionManager());

         bridge.start();

         connSource = cf0.createConnection();

         Session sessSend = connSource.createSession(false, Session.AUTO_ACKNOWLEDGE);

         MessageProducer prod = sessSend.createProducer(sourceQueue);

         for (int i = 0; i < NUM_MESSAGES; i++)
         {
            TextMessage tm = sessSend.createTextMessage("message" + i);

            if (i >= NUM_MESSAGES / 2)
            {
               tm.setStringProperty("vegetable", "radish");
            }
            else
            {
               tm.setStringProperty("vegetable", "cauliflower");
            }

            prod.send(tm);
         }

         connTarget = cf1.createConnection();

         Session sessRec = connTarget.createSession(false, Session.AUTO_ACKNOWLEDGE);

         MessageConsumer cons = sessRec.createConsumer(targetQueue);

         connTarget.start();

         for (int i = NUM_MESSAGES / 2; i < NUM_MESSAGES; i++)
         {
            TextMessage tm = (TextMessage)cons.receive(10000);

            Assert.assertNotNull(tm);

            Assert.assertEquals("message" + i, tm.getText());
         }

         Message m = cons.receiveNoWait();

         Assert.assertNull(m);

      }
      finally
      {
         if (connSource != null)
         {
            connSource.close();
         }

         if (connTarget != null)
         {
            connTarget.close();
         }

         if (bridge != null)
         {
            bridge.stop();
         }

         removeAllMessages(sourceQueue.getQueueName(), 0);
      }
   }
View Full Code Here

      internalTestStartBridgeWithJTATransactionAlreadyRunning(false);
   }

   public void internalTestStartBridgeWithJTATransactionAlreadyRunning(final boolean largeMessage) throws Exception
   {
      JMSBridgeImpl bridge = null;

      Transaction toResume = null;

      Transaction started = null;

      TransactionManager mgr = newTransactionManager();

      try
      {

         toResume = mgr.suspend();

         mgr.begin();

         started = mgr.getTransaction();

         final int NUM_MESSAGES = 10;

         bridge = new JMSBridgeImpl(cff0,
                                    cff1,
                                    sourceTopicFactory,
                                    targetQueueFactory,
                                    null,
                                    null,
                                    null,
                                    null,
                                    null,
                                    5000,
                                    10,
                                    QualityOfServiceMode.AT_MOST_ONCE,
                                    1,
                                    -1,
                                    null,
                                    null,
                                    false);
         bridge.setTransactionManager(mgr);
         bridge.start();

         sendMessages(cf0, sourceTopic, 0, NUM_MESSAGES, false, largeMessage);

         checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES, largeMessage);
      }
      finally
      {
         if (started != null)
         {
            try
            {
               started.rollback();
            }
            catch (Exception e)
            {
               JMSBridgeTest.log.error("Failed to rollback", e);
            }
         }

         if (toResume != null)
         {
            try
            {
               mgr.resume(toResume);
            }
            catch (Exception e)
            {
               JMSBridgeTest.log.error("Failed to resume", e);
            }
         }
         if (bridge != null)
         {
            bridge.stop();
         }
      }
   }
View Full Code Here

      internalTestNonDurableSubscriber(false, 1);
   }

   public void internalTestNonDurableSubscriber(final boolean largeMessage, final int batchSize) throws Exception
   {
      JMSBridgeImpl bridge = null;

      try
      {
         final int NUM_MESSAGES = 10;

         bridge = new JMSBridgeImpl(cff0,
                                    cff1,
                                    sourceTopicFactory,
                                    targetQueueFactory,
                                    null,
                                    null,
                                    null,
                                    null,
                                    null,
                                    5000,
                                    10,
                                    QualityOfServiceMode.AT_MOST_ONCE,
                                    batchSize,
                                    -1,
                                    null,
                                    null,
                                    false);
         bridge.setTransactionManager(newTransactionManager());

         bridge.start();

         sendMessages(cf0, sourceTopic, 0, NUM_MESSAGES, false, largeMessage);

         checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES, largeMessage);
      }
      finally
      {
         if (bridge != null)
         {
            bridge.stop();
         }
      }
   }
View Full Code Here

      internalTestDurableSubscriber(false, 1);
   }

   public void internalTestDurableSubscriber(final boolean largeMessage, final int batchSize) throws Exception
   {
      JMSBridgeImpl bridge = null;

      try
      {
         final int NUM_MESSAGES = 10;

         bridge = new JMSBridgeImpl(cff0,
                                    cff1,
                                    sourceTopicFactory,
                                    targetQueueFactory,
                                    null,
                                    null,
                                    null,
                                    null,
                                    null,
                                    5000,
                                    10,
                                    QualityOfServiceMode.AT_MOST_ONCE,
                                    batchSize,
                                    -1,
                                    "subTest",
                                    "clientid123",
                                    false);
         bridge.setTransactionManager(newTransactionManager());

         bridge.start();

         sendMessages(cf0, sourceTopic, 0, NUM_MESSAGES, true, largeMessage);

         checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES, largeMessage);
      }
      finally
      {
         if (bridge != null)
         {
            bridge.stop();
         }

         // Now unsubscribe
         Connection conn = cf0.createConnection();
         conn.setClientID("clientid123");
View Full Code Here

TOP

Related Classes of org.hornetq.jms.bridge.impl.JMSBridgeImpl

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.