Examples of RemotingConnection


Examples of org.hornetq.spi.core.protocol.RemotingConnection

      ClientConsumer consumer = session.createConsumer(ReattachTest.ADDRESS);

      InVMConnector.numberOfFailures = 10;
      InVMConnector.failOnCreateConnection = true;

      final RemotingConnection conn = ((ClientSessionInternal)session).getConnection();

      final RemotingConnection conn2 = ((ClientSessionInternal)session2).getConnection();

      Thread t = new Thread()
      {
         @Override
         public void run()
         {
            try
            {
               Thread.sleep(asyncFailDelay);
            }
            catch (InterruptedException ignore)
            {
            }

            conn2.fail(new HornetQException(HornetQException.NOT_CONNECTED, "Did not receive pong from server"));
         }
      };

      t.start();
View Full Code Here

Examples of org.hornetq.spi.core.protocol.RemotingConnection

      session.createConsumer(ReattachTest.ADDRESS);

      InVMConnector.failOnCreateConnection = true;

      RemotingConnection conn = ((ClientSessionInternal)session).getConnection();

      // Sleep for longer than max retries so should fail to reconnect

      Thread t = new Thread()
      {
         @Override
         public void run()
         {
            try
            {
               Thread.sleep(retryInterval * (reconnectAttempts + 1));
            }
            catch (InterruptedException ignore)
            {
            }

            InVMConnector.failOnCreateConnection = false;
         }
      };

      t.start();

      conn.fail(new HornetQException(HornetQException.NOT_CONNECTED));

      // Should throw exception since didn't reconnect

      try
      {
View Full Code Here

Examples of org.hornetq.spi.core.protocol.RemotingConnection

         sf.setReconnectAttempts(reconnectAttempts);
         sf.setConfirmationWindowSize(1024 * 1024);

         session = sf.createSession();

         final RemotingConnection connFailure = ((ClientSessionInternal)session).getConnection();

         int numberOfThreads = 100;
         final int numberOfSessionsToCreate = 10;

         final CountDownLatch alignLatch = new CountDownLatch(numberOfThreads);
         final CountDownLatch startFlag = new CountDownLatch(1);

         class CreateSessionThread extends Thread
         {
            Throwable failure;

            @Override
            public void run()
            {
               try
               {
                  alignLatch.countDown();
                  startFlag.await();
                  for (int i = 0; i < numberOfSessionsToCreate; i++)
                  {
                     Thread.yield();
                     ClientSession session = sf.createSession(false, true, true);

                     session.close();
                  }
               }
               catch (Throwable e)
               {
                  e.printStackTrace();
                  failure = e;
               }
            }
         }

         CreateSessionThread threads[] = new CreateSessionThread[numberOfThreads];
         for (int i = 0; i < numberOfThreads; i++)
         {
            threads[i] = new CreateSessionThread();
            threads[i].start();
         }

         alignLatch.await();

         timer.schedule(new TimerTask()
         {
            @Override
            public void run()
            {
               try
               {
                  connFailure.fail(new HornetQException(HornetQException.NOT_CONNECTED));
               }
               catch (Exception e)
               {
                  ReattachTest.log.warn("Error on the timer " + e);
               }
View Full Code Here

Examples of org.hornetq.spi.core.protocol.RemotingConnection

      ClientSession session = sf.createSession(false, true, true);

      // Sleep 3 times retryInterval, so it should at least have 3 retries

      RemotingConnection conn = ((ClientSessionInternal)session).getConnection();

      InVMConnector.failOnCreateConnection = false;

      conn.fail(new HornetQException(HornetQException.NOT_CONNECTED));

      Thread t = new Thread()
      {
         @Override
         public void run()
View Full Code Here

Examples of org.hornetq.spi.core.protocol.RemotingConnection

      ClientConsumer consumer = session.createConsumer(ReattachTest.ADDRESS);

      InVMConnector.failOnCreateConnection = true;
      InVMConnector.numberOfFailures = reconnectAttempts - 1;

      RemotingConnection conn = ((ClientSessionInternal)session).getConnection();

      conn.fail(new HornetQException(HornetQException.NOT_CONNECTED));

      session.start();

      for (int i = 0; i < numMessages; i++)
      {
View Full Code Here

Examples of org.hornetq.spi.core.protocol.RemotingConnection

      ClientConsumer consumer = session.createConsumer(ReattachTest.ADDRESS);

      InVMConnector.failOnCreateConnection = true;

      RemotingConnection conn = ((ClientSessionInternal)session).getConnection();

      long start = System.currentTimeMillis();

      Thread t = new Thread()
      {
         @Override
         public void run()
         {
            try
            {
               Thread.sleep(retryInterval / 2);
            }
            catch (InterruptedException ignore)
            {
            }
            InVMConnector.failOnCreateConnection = false;
         }
      };

      t.start();

      conn.fail(new HornetQException(HornetQException.NOT_CONNECTED));

      session.start();

      for (int i = 0; i < numMessages; i++)
      {
View Full Code Here

Examples of org.hornetq.spi.core.protocol.RemotingConnection

      ClientConsumer consumer = session.createConsumer(ReattachTest.ADDRESS);

      InVMConnector.failOnCreateConnection = true;
      InVMConnector.numberOfFailures = 3;

      RemotingConnection conn = ((ClientSessionInternal)session).getConnection();

      long start = System.currentTimeMillis();

      conn.fail(new HornetQException(HornetQException.NOT_CONNECTED));

      session.start();

      for (int i = 0; i < numMessages; i++)
      {
View Full Code Here

Examples of org.hornetq.spi.core.protocol.RemotingConnection

      ClientConsumer consumer = session.createConsumer(ReattachTest.ADDRESS);

      InVMConnector.failOnCreateConnection = true;
      InVMConnector.numberOfFailures = 3;

      RemotingConnection conn = ((ClientSessionInternal)session).getConnection();

      long start = System.currentTimeMillis();

      conn.fail(new HornetQException(HornetQException.NOT_CONNECTED));

      session.start();

      for (int i = 0; i < numMessages; i++)
      {
View Full Code Here

Examples of org.hornetq.spi.core.protocol.RemotingConnection

      // Now fail the underlying connection

      ClientSessionInternal sessi = (ClientSessionInternal)((HornetQSession)sess).getCoreSession();

      RemotingConnection rc = sessi.getConnection();

      rc.fail(new HornetQException(HornetQException.INTERNAL_ERROR));

      // Now close the connection

      conn.close();
View Full Code Here

Examples of org.hornetq.spi.core.protocol.RemotingConnection

    * @param latch
    * @throws InterruptedException
    */
   private void failSession(final ClientSession session, final CountDownLatch latch) throws InterruptedException
   {
      RemotingConnection conn = ((ClientSessionInternal)session).getConnection();

      // Simulate failure on connection
      conn.fail(new HornetQException(HornetQException.NOT_CONNECTED));

      // Wait to be informed of failure

      Assert.assertTrue(latch.await(5000, TimeUnit.MILLISECONDS));
   }
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.