Package org.hornetq.core.client.impl

Examples of org.hornetq.core.client.impl.ClientSessionInternal


      HornetQServer server = createServer(false, isNetty);

      server.start();

      ClientSessionInternal session = null;

      try
      {
         ServerLocator locator = createFactory(isNetty);
         locator.setClientFailureCheckPeriod(pingPeriod);
         locator.setRetryInterval(500);
         locator.setRetryIntervalMultiplier(1d);
         locator.setReconnectAttempts(-1);
         locator.setConfirmationWindowSize(1024 * 1024);
         ClientSessionFactory factory = locator.createSessionFactory();


         session = (ClientSessionInternal)factory.createSession();

         final AtomicInteger count = new AtomicInteger(0);

         final CountDownLatch latch = new CountDownLatch(1);

         session.addFailureListener(new SessionFailureListener()
         {

            public void connectionFailed(final HornetQException me, boolean failedOver)
            {
               count.incrementAndGet();
               latch.countDown();
            }

            public void beforeReconnect(final HornetQException exception)
            {
            }

         });

         server.stop();

         Thread.sleep((pingPeriod * 2));

         server.start();

         Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));

         // Some time to let possible loops to occur
         Thread.sleep(500);

         Assert.assertEquals(1, count.get());

         locator.close();
      }
      finally
      {
         try
         {
            session.close();
         }
         catch (Throwable e)
         {
         }

View Full Code Here


   protected void crash(final ClientSession... sessions) throws Exception
   {
      for (ClientSession session : sessions)
      {
         log.debug("Crashing session " + session);
         ClientSessionInternal internalSession = (ClientSessionInternal) session;
         internalSession.getConnection().fail(new HornetQException(HornetQException.NOT_CONNECTED, "oops"));
      }
   }
View Full Code Here

      // ClusterListener

      public void nodeUP(TopologyMember member, boolean last)
      {
         ClientSessionInternal sessionToUse = session;
         RemotingConnection connectionToUse = sessionToUse != null ? sessionToUse.getConnection() : null;

         if (member != null && BridgeImpl.this.targetNodeID != null && BridgeImpl.this.targetNodeID.equals(member.getNodeId()))
         {
            // this could be an update of the topology say after a backup started
            BridgeImpl.this.targetNode = member;
View Full Code Here

      for (HornetQSession session : sessions)
      {
         ClientSession coreSession = session.getCoreSession();
         if (coreSession instanceof ClientSessionInternal)
         {
            ClientSessionInternal internalSession = (ClientSessionInternal) coreSession;
            internalSession.setStopSignal();
         }
      }

   }
View Full Code Here

      QueueBrowser browser = session1.createBrowser(queue);

      // Now fail the underlying connection

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

      RemotingConnection rc = sessi.getConnection();

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

      // Now close the connection
View Full Code Here

         // Make sure we have a short connection TTL so sessions will be quickly closed on the server
         long ttl = 500;
         server.getConfiguration().setConnectionTTLOverride(ttl);
         server.start();
         ClientSessionFactory cf = locator.createSessionFactory();
         ClientSessionInternal clientSession = (ClientSessionInternal)cf.createSession(false, true, true);
         clientSession.createQueue(queueName, queueName, false);
         ClientProducer producer = clientSession.createProducer();
         ClientConsumer consumer = clientSession.createConsumer(queueName);

         Assert.assertEquals(1, server.getRemotingService().getConnections().size());

         RemotingConnection rc = clientSession.getConnection();

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

         clientSession.close();

         long start = System.currentTimeMillis();

         while (true)
         {
View Full Code Here

      CountDownLatch latch = new CountDownLatch(1);
      MyExceptionListener listener = new MyExceptionListener(latch);

      conn.setExceptionListener(listener);

      ClientSessionInternal coreSession = (ClientSessionInternal)((HornetQConnection)conn).getInitialSession();

      coreSession.getConnection().fail(new HornetQException(HornetQException.INTERNAL_ERROR, "blah"));

      latch.await(5, TimeUnit.SECONDS);

      Assert.assertEquals(1, listener.numCalls);
View Full Code Here

      Session sess2 = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);

      Session sess3 = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);

      ClientSessionInternal coreSession0 = (ClientSessionInternal)((HornetQConnection)conn).getInitialSession();

      ClientSessionInternal coreSession1 = (ClientSessionInternal)((HornetQSession)sess1).getCoreSession();

      ClientSessionInternal coreSession2 = (ClientSessionInternal)((HornetQSession)sess2).getCoreSession();

      ClientSessionInternal coreSession3 = (ClientSessionInternal)((HornetQSession)sess3).getCoreSession();

      coreSession0.getConnection().fail(new HornetQException(HornetQException.INTERNAL_ERROR, "blah"));

      coreSession1.getConnection().fail(new HornetQException(HornetQException.INTERNAL_ERROR, "blah"));

      coreSession2.getConnection().fail(new HornetQException(HornetQException.INTERNAL_ERROR, "blah"));

      coreSession3.getConnection().fail(new HornetQException(HornetQException.INTERNAL_ERROR, "blah"));

      latch.await(5, TimeUnit.SECONDS);
      // Listener should only be called once even if all sessions connections die
      Assert.assertEquals(1, listener.numCalls);
View Full Code Here

      for (HornetQSession session : sessions)
      {
         ClientSession coreSession = session.getCoreSession();
         if (coreSession instanceof ClientSessionInternal)
         {
            ClientSessionInternal internalSession = (ClientSessionInternal)coreSession;
            internalSession.setStopSignal();
         }
      }

   }
View Full Code Here

      for (HornetQSession session : sessions)
      {
         ClientSession coreSession = session.getCoreSession();
         if (coreSession instanceof ClientSessionInternal)
         {
            ClientSessionInternal internalSession = (ClientSessionInternal)coreSession;
            internalSession.setStopSignal();
         }
      }

   }
View Full Code Here

TOP

Related Classes of org.hornetq.core.client.impl.ClientSessionInternal

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.