Package org.hornetq.api.jms.management

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


       params = {@ManagementParameter(name = "name", description = "the queue name")})
   @MetaMapping(value = AddressSettingsMapper.class)
   public Object[] getQueueConfiguration(String name) throws Exception
   {
      Object[] config = new Object[3];
      JMSQueueControl control = (JMSQueueControl) managementService.getResource(name);
      JMSQueueConfiguration queueConfiguration = new JMSQueueConfigurationImpl(control.getName(), control.getSelector(), !control.isTemporary(), control.getJNDIBindings());
      config[0] = queueConfiguration;
      String addressSettingsAsJSON = hornetQServerControl.getAddressSettingsAsJSON(name);
      config[1] = AddressSettingsInfo.from(addressSettingsAsJSON);
      String rolesAsJSON = hornetQServerControl.getRolesAsJSON(name);
      RoleInfo[] roles = RoleInfo.from(rolesAsJSON);
View Full Code Here


       params = {
           @ManagementParameter(name = "name", description = "the queue name"),
           @ManagementParameter(name = "names", description = "the measurement names")})
   public String[] getQueueMeasurements(String name, String[] names) throws Exception
   {
      JMSQueueControl control = (JMSQueueControl) managementService.getResource(name);
      String[] val = new String[names.length];
      for (int i = 0, valLength = val.length; i < valLength; i++)
      {
         Object o = control.getClass().getMethod(names[i]).invoke(control);
         if(o instanceof Object[])
         {
            val[i] = coomaSeparatedString((Object[]) o);
         }
         else
View Full Code Here

           @ManagementParameter(name = "name", description = "the queue name"),
           @ManagementParameter(name = "method", description = "the method"),
           @ManagementParameter(name = "params", description = "the method params")})
   public Object invokeQueueOperation(String name, String method, String[] params, String[] type) throws Exception
   {
      JMSQueueControl control = (JMSQueueControl) managementService.getResource(name);
      Class[] classes = getClassTypes(type);
      Method m = control.getClass().getMethod(method, classes);
      return m.invoke(control, getParams(params, classes));
   }
View Full Code Here

           @ManagementParameter(name = "method", description = "the method"),
           @ManagementParameter(name = "params", description = "the method params")})
   @MetaMapping(value = MessageListMapper.class)
   public List invokeQueueOperationMessageType(String name, String method, String[] params, String[] type) throws Exception
   {
      JMSQueueControl control = (JMSQueueControl) managementService.getResource(name);
      Class[] classes = getClassTypes(type);
      Method m = control.getClass().getMethod(method, classes);
      Map<String, Serializable>[] maps = (Map<String, Serializable>[]) m.invoke(control, getParams(params, classes));
      List list = new ArrayList();
      list.addAll(Arrays.asList(maps));
      return list;
   }
View Full Code Here

         params = {
           @ManagementParameter(name = "name", description = "the queue name")
   })
   public boolean isPaused(String name) throws Exception
   {
     JMSQueueControl control = (JMSQueueControl) managementService.getResource(name);
     return control.isPaused();
   }
View Full Code Here

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

   public void testGetAttributes() throws Exception
   {
      JMSQueueControl queueControl = createManagementControl();

      Assert.assertEquals(queue.getName(), queueControl.getName());
      Assert.assertEquals(queue.getAddress(), queueControl.getAddress());
      Assert.assertEquals(queue.isTemporary(), queueControl.isTemporary());
   }
View Full Code Here

      Assert.assertEquals(queue.isTemporary(), queueControl.isTemporary());
   }

   public void testGetXXXCount() throws Exception
   {
      JMSQueueControl queueControl = createManagementControl();

      Assert.assertEquals(0, queueControl.getMessageCount());
      Assert.assertEquals(0, queueControl.getConsumerCount());

      Connection connection = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
      MessageConsumer consumer = JMSUtil.createConsumer(connection, queue);

      Assert.assertEquals(1, queueControl.getConsumerCount());

      JSONArray jsonArray = new JSONArray(queueControl.listConsumersAsJSON());

      assertEquals(1, jsonArray.length());

      JMSUtil.sendMessages(queue, 2);

      Assert.assertEquals(2, queueControl.getMessageCount());
      Assert.assertEquals(2, queueControl.getMessagesAdded());

      connection.start();

      Assert.assertNotNull(consumer.receive(500));
      Assert.assertNotNull(consumer.receive(500));

      Assert.assertEquals(0, queueControl.getMessageCount());
      Assert.assertEquals(2, queueControl.getMessagesAdded());

      consumer.close();

      Assert.assertEquals(0, queueControl.getConsumerCount());

      connection.close();
   }
View Full Code Here

      connection.close();
   }

   public void testListMessagesWithNullFilter() throws Exception
   {
      JMSQueueControl queueControl = createManagementControl();

      Assert.assertEquals(0, queueControl.getMessageCount());

      String[] ids = JMSUtil.sendMessages(queue, 2);

      Assert.assertEquals(2, queueControl.getMessageCount());

      Map<String, Object>[] data = queueControl.listMessages(null);
      Assert.assertEquals(2, data.length);
      System.out.println(data[0].keySet());
      Assert.assertEquals(ids[0], data[0].get("JMSMessageID").toString());
      Assert.assertEquals(ids[1], data[1].get("JMSMessageID").toString());

      JMSUtil.consumeMessages(2, queue);

      data = queueControl.listMessages(null);
      Assert.assertEquals(0, data.length);
   }
View Full Code Here

      Assert.assertEquals(0, data.length);
   }

   public void testListMessagesAsJSONWithNullFilter() throws Exception
   {
      JMSQueueControl queueControl = createManagementControl();

      Assert.assertEquals(0, queueControl.getMessageCount());

      String[] ids = JMSUtil.sendMessages(queue, 2);

      Assert.assertEquals(2, queueControl.getMessageCount());

      String jsonString = queueControl.listMessagesAsJSON(null);
      Assert.assertNotNull(jsonString);
      JSONArray array = new JSONArray(jsonString);
      Assert.assertEquals(2, array.length());
      Assert.assertEquals(ids[0], array.getJSONObject(0).get("JMSMessageID"));
      Assert.assertEquals(ids[1], array.getJSONObject(1).get("JMSMessageID"));

      JMSUtil.consumeMessages(2, queue);

      jsonString = queueControl.listMessagesAsJSON(null);
      Assert.assertNotNull(jsonString);
      array = new JSONArray(jsonString);
      Assert.assertEquals(0, array.length());
   }
View Full Code Here

      Assert.assertEquals(0, array.length());
   }

   public void testRemoveMessage() throws Exception
   {
      JMSQueueControl queueControl = createManagementControl();

      Assert.assertEquals(0, queueControl.getMessageCount());

      JMSUtil.sendMessages(queue, 2);

      Assert.assertEquals(2, queueControl.getMessageCount());

      Map<String, Object>[] data = queueControl.listMessages(null);
      Assert.assertEquals(2, data.length);

      System.out.println(data[0]);
      // retrieve the first message info
      Set<String> keySet = data[0].keySet();
      Iterator<String> it = keySet.iterator();
      while (it.hasNext())
      {
         System.out.println(it.next());
      }
      String messageID = (String)data[0].get("JMSMessageID");

      queueControl.removeMessage(messageID.toString());

      Assert.assertEquals(1, queueControl.getMessageCount());
   }
View Full Code Here

TOP

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

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.