Package org.hornetq.api.jms.management

Examples of org.hornetq.api.jms.management.JMSServerControl


      String binding = RandomUtil.randomString();

      UnitTestCase.checkNoBinding(context, binding);
      checkNoResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName));

      JMSServerControl control = ManagementControlHelper.createJMSServerControl(mbeanServer);
      control.createQueue(queueName, binding);

      Object o = UnitTestCase.checkBinding(context, binding);
      Assert.assertTrue(o instanceof Queue);
      Queue queue = (Queue)o;
      assertEquals(queueName, queue.getQueueName());
View Full Code Here


   {
      try
      {
         startHornetQServer(acceptorFactory);

         JMSServerControl control = createManagementControl();

         Assert.assertEquals(0, control.listConnectionIDs().length);

         ConnectionFactory cf1 = JMSUtil.createFactory(connectorFactory,
                                                       JMSServerControl2Test.CONNECTION_TTL,
                                                       JMSServerControl2Test.PING_PERIOD);
         Connection connection = cf1.createConnection();

         String[] connectionIDs = control.listConnectionIDs();
         Assert.assertEquals(1, connectionIDs.length);

         ConnectionFactory cf2 = JMSUtil.createFactory(connectorFactory,
                                                       JMSServerControl2Test.CONNECTION_TTL,
                                                       JMSServerControl2Test.PING_PERIOD);
         Connection connection2 = cf2.createConnection();
         Assert.assertEquals(2, control.listConnectionIDs().length);

         connection.close();

         waitForConnectionIDs(1, control);
View Full Code Here

   {
      try
      {
         startHornetQServer(acceptorFactory);

         JMSServerControl control = createManagementControl();

         Assert.assertEquals(0, control.listConnectionIDs().length);

         ConnectionFactory cf = JMSUtil.createFactory(connectorFactory,
                                                      JMSServerControl2Test.CONNECTION_TTL,
                                                      JMSServerControl2Test.PING_PERIOD);
         Connection connection = cf.createConnection();

         String[] connectionIDs = control.listConnectionIDs();
         Assert.assertEquals(1, connectionIDs.length);
         String connectionID = connectionIDs[0];

         String[] sessions = control.listSessions(connectionID);
         Assert.assertEquals(1, sessions.length);
         connection.close();
         sessions = control.listSessions(connectionID);
         Assert.assertEquals("got " + Arrays.asList(sessions), 0, sessions.length);

         connection.close();

         waitForConnectionIDs(0, control);

         Assert.assertEquals(0, control.listConnectionIDs().length);
      }
      finally
      {
         if (serverManager != null)
         {
View Full Code Here

   {
      try
      {
         startHornetQServer(acceptorFactory);

         JMSServerControl control = createManagementControl();

         Assert.assertEquals(0, control.listRemoteAddresses().length);

         ConnectionFactory cf = JMSUtil.createFactory(connectorFactory,
                                                      JMSServerControl2Test.CONNECTION_TTL,
                                                      JMSServerControl2Test.PING_PERIOD);
         Connection connection = cf.createConnection();

         String[] remoteAddresses = control.listRemoteAddresses();
         Assert.assertEquals(1, remoteAddresses.length);

         for (String remoteAddress : remoteAddresses)
         {
            System.out.println(remoteAddress);
         }

         connection.close();

         waitForConnectionIDs(0, control);

         remoteAddresses = control.listRemoteAddresses();
         Assert.assertEquals("got " + Arrays.asList(remoteAddresses), 0, remoteAddresses.length);
      }
      finally
      {
         if (serverManager != null)
View Full Code Here

   {
      try
      {
         startHornetQServer(acceptorFactory);

         JMSServerControl control = createManagementControl();

         Assert.assertEquals(0, server.getConnectionCount());
         Assert.assertEquals(0, control.listRemoteAddresses().length);

         ConnectionFactory cf = JMSUtil.createFactory(connectorFactory,
                                                      JMSServerControl2Test.CONNECTION_TTL,
                                                      JMSServerControl2Test.PING_PERIOD);
         Connection connection = cf.createConnection();

         Assert.assertEquals(1, server.getConnectionCount());

         String[] remoteAddresses = control.listRemoteAddresses();
         Assert.assertEquals(1, remoteAddresses.length);
         String remoteAddress = remoteAddresses[0];

         final CountDownLatch exceptionLatch = new CountDownLatch(1);
         connection.setExceptionListener(new ExceptionListener()
         {
            public void onException(final JMSException e)
            {
               exceptionLatch.countDown();
            }
         });

         Assert.assertTrue(control.closeConnectionsForAddress(remoteAddress));

         boolean gotException = exceptionLatch.await(2 * JMSServerControl2Test.CONNECTION_TTL, TimeUnit.MILLISECONDS);
         Assert.assertTrue("did not received the expected JMSException", gotException);

         remoteAddresses = control.listRemoteAddresses();
         Assert.assertEquals("got " + Arrays.asList(remoteAddresses), 0, remoteAddresses.length);
         Assert.assertEquals(0, server.getConnectionCount());

         connection.close();
      }
View Full Code Here

      try
      {
         startHornetQServer(acceptorFactory);

         JMSServerControl control = createManagementControl();

         Assert.assertEquals(0, server.getConnectionCount());
         Assert.assertEquals(0, control.listRemoteAddresses().length);

         ConnectionFactory cf = JMSUtil.createFactory(connectorFactory,
                                                      JMSServerControl2Test.CONNECTION_TTL,
                                                      JMSServerControl2Test.PING_PERIOD);
         Connection connection = cf.createConnection();

         Assert.assertEquals(1, server.getConnectionCount());
         String[] remoteAddresses = control.listRemoteAddresses();
         Assert.assertEquals(1, remoteAddresses.length);

         final CountDownLatch exceptionLatch = new CountDownLatch(1);
         connection.setExceptionListener(new ExceptionListener()
         {
            public void onException(final JMSException e)
            {
               exceptionLatch.countDown();
            }
         });

         Assert.assertFalse(control.closeConnectionsForAddress(unknownAddress));

         boolean gotException = exceptionLatch.await(2 * JMSServerControl2Test.CONNECTION_TTL, TimeUnit.MILLISECONDS);
         Assert.assertFalse(gotException);

         Assert.assertEquals(1, control.listRemoteAddresses().length);
         Assert.assertEquals(1, server.getConnectionCount());

         connection.close();

      }
View Full Code Here

      String binding = RandomUtil.randomString();

      UnitTestCase.checkNoBinding(context, binding);
      checkNoResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName));

      JMSServerControl control = ManagementControlHelper.createJMSServerControl(mbeanServer);
      control.createQueue(queueName, binding);

      Object o = UnitTestCase.checkBinding(context, binding);
      Assert.assertTrue(o instanceof Queue);
      Queue queue = (Queue)o;
      assertEquals(queueName, queue.getQueueName());
View Full Code Here

   }
  
   // The JMS test won't support the server being restarted, hence we have to do a slight different test on that case
   public void testCreateConnectionFactory_CompleteList() throws Exception
   {
      JMSServerControl control = createManagementControl();
      control.createConnectionFactory("test", //name
                                      true, // ha
                                      false, // useDiscovery
                                      1, // cfType
                                      "invm", // connectorNames
                                      "tst", // jndiBindins
View Full Code Here

   protected JMSServerControl createManagementControl() throws Exception
   {
      HornetQQueue managementQueue = (HornetQQueue)HornetQJMSClient.createQueue("hornetq.management");
      final JMSMessagingProxy proxy = new JMSMessagingProxy(session, managementQueue, ResourceNames.JMS_SERVER);

      return new JMSServerControl()
      {

         public boolean closeConnectionsForAddress(final String ipAddress) throws Exception
         {
            return (Boolean)proxy.invokeOperation("closeConnectionsForAddress", ipAddress);
View Full Code Here

   // Public --------------------------------------------------------

   public void testCreateCF() throws Exception
   {
      JMSServerControl control = createJMSControl();
      control.createConnectionFactory("test", false, false, 0, "invm", "test");

      ConnectionFactoryControl controlCF = createCFControl("test");

      HornetQConnectionFactory cf = (HornetQConnectionFactory)ctx.lookup("test");
View Full Code Here

TOP

Related Classes of org.hornetq.api.jms.management.JMSServerControl

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.