Package org.hornetq.tests.integration.cluster.util

Examples of org.hornetq.tests.integration.cluster.util.TestableServer


      int newLive = -1;
      while (true)
      {
         for (int node : nodes)
         {
            TestableServer backupServer = servers.get(node);
            if (newLive == -1 && backupServer.isInitialised())
            {
               newLive = node;
            }
            else if (newLive != -1)
            {
View Full Code Here


      return new RemoteProcessHornetQServer(SharedBackupServerConfiguration.class.getName());
   }
  
   public void testCrashLiveServer() throws Exception
   {
      TestableServer liveServer = null;
      TestableServer backupServer = null;
      try
      {
         liveServer = createLiveServer();
         backupServer = createBackupServer();
        
         liveServer.start();
         backupServer.start();
        
         ServerLocator locator = HornetQClient.createServerLocatorWithHA(createTransportConfiguration(true,
                                                                                                      false,
                                                                                                      generateParams(0,
                                                                                                                     true)));
         locator.setFailoverOnInitialConnection(true);

         ClientSessionFactory sf = locator.createSessionFactory();
         ClientSession prodSession = sf.createSession();
         prodSession.createQueue("foo", "bar", true);
         ClientProducer producer = prodSession.createProducer("foo");
         ClientMessage message = prodSession.createMessage(true);
         message.putStringProperty("key", "value");
         producer.send(message);
         prodSession.commit();
         prodSession.close();

         liveServer.crash();
         liveServer = null;
         Thread.sleep(5000);

         sf = locator.createSessionFactory();
         ClientSession consSession = sf.createSession();
         consSession.start();
         ClientConsumer consumer = consSession.createConsumer("bar");
         ClientMessage receivedMessage = consumer.receive(5000);
         assertNotNull(receivedMessage);
         assertEquals(message.getStringProperty("key"), receivedMessage.getStringProperty("key"));
         receivedMessage.acknowledge();

         consumer.close();
         consSession.deleteQueue("bar");
         locator.close();

      }
      catch(Exception e)
      {
         e.printStackTrace();
      }
      finally
      {
         if (liveServer != null)
         {
            liveServer.stop();
         }
         if (backupServer != null)
         {
            backupServer.stop();
         }
      }

   }
View Full Code Here

      return new RemoteProcessHornetQServer(SharedBackupServerConfiguration.class.getName());
   }
  
   public void testCrashLiveServer() throws Exception
   {
      TestableServer liveServer = null;
      TestableServer backupServer = null;
      try
      {
         liveServer = createLiveServer();
         backupServer = createBackupServer();
        
         liveServer.start();
         backupServer.start();
        
         ServerLocator locator = HornetQClient.createServerLocatorWithHA(createTransportConfiguration(true,
                                                                                                      false,
                                                                                                      generateParams(0,
                                                                                                                     true)));
         locator.setFailoverOnInitialConnection(true);

         ClientSessionFactory sf = locator.createSessionFactory();
         ClientSession prodSession = sf.createSession();
         prodSession.createQueue("foo", "bar", true);
         ClientProducer producer = prodSession.createProducer("foo");
         ClientMessage message = prodSession.createMessage(true);
         message.putStringProperty("key", "value");
         producer.send(message);
         prodSession.commit();
         prodSession.close();

         liveServer.crash();
         liveServer = null;
         Thread.sleep(5000);

         sf = locator.createSessionFactory();
         ClientSession consSession = sf.createSession();
         consSession.start();
         ClientConsumer consumer = consSession.createConsumer("bar");
         ClientMessage receivedMessage = consumer.receive(5000);
         assertNotNull(receivedMessage);
         assertEquals(message.getStringProperty("key"), receivedMessage.getStringProperty("key"));
         receivedMessage.acknowledge();

         consumer.close();
         consSession.deleteQueue("bar");
         locator.close();

      }
      catch(Exception e)
      {
         e.printStackTrace();
      }
      finally
      {
         if (liveServer != null)
         {
            liveServer.stop();
         }
         if (backupServer != null)
         {
            backupServer.stop();
         }
      }

   }
View Full Code Here

      int newLive = -1;
      while (true)
      {
         for (int node : nodes)
         {
            TestableServer backupServer = servers.get(node);
            if (newLive == -1 && backupServer.isInitialised())
            {
               newLive = node;
            }
            else if(newLive != -1)
            {
View Full Code Here

      return new RemoteProcessHornetQServer(SharedBackupServerConfiguration.class.getName());
   }

   public void testCrashLiveServer() throws Exception
   {
      TestableServer liveServer = null;
      TestableServer backupServer = null;
      try
      {
         liveServer = createLiveServer();
         backupServer = createBackupServer();

         liveServer.start();
         backupServer.start();

         ServerLocator locator = HornetQClient.createServerLocatorWithHA(createTransportConfiguration(true,
                                                                                                      false,
                                                                                                      generateParams(0,
                                                                                                                     true)));
         locator.setFailoverOnInitialConnection(true);

         ClientSessionFactory sf = locator.createSessionFactory();
         ClientSession prodSession = sf.createSession();
         prodSession.createQueue("foo", "bar", true);
         ClientProducer producer = prodSession.createProducer("foo");
         ClientMessage message = prodSession.createMessage(true);
         message.putStringProperty("key", "value");
         producer.send(message);
         prodSession.commit();
         prodSession.close();

         liveServer.crash();
         liveServer = null;
         Thread.sleep(5000);

         sf = locator.createSessionFactory();
         ClientSession consSession = sf.createSession();
         consSession.start();
         ClientConsumer consumer = consSession.createConsumer("bar");
         ClientMessage receivedMessage = consumer.receive(5000);
         assertNotNull(receivedMessage);
         assertEquals(message.getStringProperty("key"), receivedMessage.getStringProperty("key"));
         receivedMessage.acknowledge();

         consumer.close();
         consSession.deleteQueue("bar");
         locator.close();

      }
      catch(Exception e)
      {
         e.printStackTrace();
      }
      finally
      {
         if (liveServer != null)
         {
            liveServer.stop();
         }
         if (backupServer != null)
         {
            backupServer.stop();
         }
      }

   }
View Full Code Here

TOP

Related Classes of org.hornetq.tests.integration.cluster.util.TestableServer

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.