Examples of MessageCounter


Examples of org.jboss.jms.server.messagecounter.MessageCounter

   {
      List counters = getMessageCounters();

      Collections.sort(counters, new Comparator() {
        public int compare(Object o1, Object o2) {
          MessageCounter m1 = (MessageCounter)o1;
          MessageCounter m2 = (MessageCounter)o2;
          return m1.getDestinationName().compareTo(m2.getDestinationName());
        }
      });

      String ret =
         "<table width=\"100%\" border=\"1\" cellpadding=\"1\" cellspacing=\"1\">"
            + "<tr>"
            + "<th>Type</th>"
            + "<th>Name</th>"
            + "<th>Subscription</th>"
            + "<th>Durable</th>"
            + "<th>Count</th>"
            + "<th>CountDelta</th>"
            + "<th>Depth</th>"
            + "<th>DepthDelta</th>"
            + "<th>Last Add</th>"
            + "</tr>";

      String strNameLast = null;
      String strTypeLast = null;
      String strDestLast = null;

      String destData = "";
      int destCount = 0;

      int countTotal = 0;
      int countDeltaTotal = 0;
      int depthTotal = 0;
      int depthDeltaTotal = 0;

      int i = 0; // define outside of for statement, so variable
      // still exists after for loop, because it is
      // needed during output of last module data string

      Iterator iter = counters.iterator();
     
      while (iter.hasNext())
      {
         MessageCounter counter = (MessageCounter)iter.next();
        
         // get counter data
         StringTokenizer tokens = new StringTokenizer(counter.getCounterAsString(), ",");

         String strType = tokens.nextToken();
         String strName = tokens.nextToken();
         String strSub = tokens.nextToken();
         String strDurable = tokens.nextToken();
View Full Code Here

Examples of org.jboss.jms.server.messagecounter.MessageCounter

        
         Iterator iter = counters.iterator();
        
         while (iter.hasNext())
         {
            MessageCounter counter = (MessageCounter)iter.next();
           
            assertEquals(0, counter.getCount());
           
            assertEquals(0, counter.getCountDelta());
           
            assertEquals(-1, counter.getHistoryLimit());
           
         }
        
         //Create a temp queue
        
         TemporaryQueue tempQueue = sess.createTemporaryQueue();
        
         counters = (List)
         ServerManagement.getAttribute(ServerManagement.getServerPeerObjectName(), "MessageCounters");
     
         assertNotNull(counters);
     
         //Temp queues don't have counters
         assertEquals(6, counters.size());
        
         //Send some messages
        
         MessageProducer prod = sess.createProducer(null);
        
         TextMessage tm1 = sess.createTextMessage("message1");
        
         TextMessage tm2 = sess.createTextMessage("message2");
        
         TextMessage tm3 = sess.createTextMessage("message3");
        
         prod.send(queue1, tm1);        
         prod.send(queue1, tm2);        
         prod.send(queue1, tm3);
        
         prod.send(queue2, tm1);        
         prod.send(queue2, tm2);        
         prod.send(queue2, tm3);
        
         prod.send(queue3, tm1);        
         prod.send(queue3, tm2);        
         prod.send(queue3, tm3);
        
         prod.send(tempQueue, tm1);        
         prod.send(tempQueue, tm2);        
         prod.send(tempQueue, tm3);
        
         prod.send(topic1, tm1);        
         prod.send(topic1, tm2);        
         prod.send(topic1, tm3);
        
         prod.send(topic2, tm1);        
         prod.send(topic2, tm2);        
         prod.send(topic2, tm3);
        
         iter = counters.iterator();
        
         //Wait until the stats are updated
         Thread.sleep(1500);
        
         while (iter.hasNext())
         {
            MessageCounter counter = (MessageCounter)iter.next();
           
            assertEquals(3, counter.getCount());
           
            assertEquals(3, counter.getCountDelta());
           
            assertEquals(-1, counter.getHistoryLimit());
           
         }
        
         while (iter.hasNext())
         {
            MessageCounter counter = (MessageCounter)iter.next();
               
            assertEquals(3, counter.getCount());
           
            assertEquals(0, counter.getCountDelta());
           
            assertEquals(-1, counter.getHistoryLimit());
           
         }
           
         ServerManagement.invoke(ServerManagement.getServerPeerObjectName(), "resetAllMessageCounters", null, null);
        
         ServerManagement.invoke(ServerManagement.getServerPeerObjectName(), "resetAllMessageCounterHistories", null, null);
        
        
         while (iter.hasNext())
         {
            MessageCounter counter = (MessageCounter)iter.next();
           
            assertEquals(0, counter.getCount());
           
            assertEquals(0, counter.getCountDelta());
           
            assertEquals(-1, counter.getHistoryLimit());           
         }
        
         String html = (String)ServerManagement.invoke(ServerManagement.getServerPeerObjectName(), "listMessageCountersAsHTML", null, null);
        
         assertNotNull(html);
        
         while (iter.hasNext())
         {
            MessageCounter counter = (MessageCounter)iter.next();

            assertTrue(html.indexOf(counter.getDestinationName()) != -1);          
         }
        
         List stats = (List)ServerManagement.getAttribute(ServerManagement.getServerPeerObjectName(), "MessageStatistics");
        
         assertNotNull(stats);
View Full Code Here

Examples of org.jboss.jms.server.messagecounter.MessageCounter

              
         String queueON = "jboss.messaging.destination:service=Queue,name=testQueue";
        
         String topicON = "jboss.messaging.destination:service=Topic,name=testTopic";
           
         MessageCounter queueCounter = (MessageCounter)ServerManagement.getAttribute(new ObjectName(queueON), "MessageCounter");
        
         assertEquals(defaultLimit, queueCounter.getHistoryLimit());
        
         conn = cf.createConnection();
        
         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
        
         sess.createConsumer(testTopic);
        
         List counters = (List)ServerManagement.getAttribute(new ObjectName(topicON), "MessageCounters");
        
         assertNotNull(counters);
        
         assertEquals(1, counters.size());
        
         MessageCounter subCounter = (MessageCounter)counters.get(0);
        
         assertEquals(defaultLimit, subCounter.getHistoryLimit());
        
         int overrideLimit = 777;
        
         ServerManagement.setAttribute(new ObjectName(queueON), "MessageCounterHistoryDayLimit", String.valueOf(overrideLimit));
        
         ServerManagement.setAttribute(new ObjectName(topicON), "MessageCounterHistoryDayLimit", String.valueOf(overrideLimit));
        
         assertEquals(overrideLimit, queueCounter.getHistoryLimit());
        
         assertEquals(overrideLimit, subCounter.getHistoryLimit());
      }
      finally
      {
         if (conn != null) conn.close();
        
View Full Code Here

Examples of org.jboss.jms.server.messagecounter.MessageCounter

      ObjectName destObjectName =
         new ObjectName("jboss.messaging.destination:service=Queue,name=QueueMessageCounter");
     
      //Most of this is tested in ServerPeerTest
     
      MessageCounter counter = (MessageCounter)ServerManagement.getAttribute(destObjectName, "MessageCounter");
     
      assertNotNull(counter);
     
      assertEquals(0, counter.getCount());
     
      assertEquals(0, counter.getCountDelta());
     
      assertEquals(-1, counter.getHistoryLimit());
     
      Connection conn = cf.createConnection();
     
      Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
     
      MessageProducer prod = sess.createProducer(queue);
     
      TextMessage tm1 = sess.createTextMessage("message1");
      prod.send(tm1);
     
      TextMessage tm2 = sess.createTextMessage("message2");
      prod.send(tm2);
     
      TextMessage tm3 = sess.createTextMessage("message3");
      prod.send(tm3);
     
      Thread.sleep(1500);
     
      assertEquals(3, counter.getCount());
     
      assertEquals(3, counter.getCountDelta());
     
      assertEquals(3, counter.getCount());
     
      assertEquals(0, counter.getCountDelta());
     
      MessageStatistics stats = (MessageStatistics)ServerManagement.getAttribute(destObjectName, "MessageStatistics");
     
      assertNotNull(stats);
     
      assertEquals(3, stats.getCount());
     
      assertEquals(0, stats.getCountDelta());
     
      assertEquals(3, stats.getDepth());
     
      ServerManagement.invoke(destObjectName, "resetMessageCounter", null, null);
     
      assertEquals(0, counter.getCount());
     
      ServerManagement.invoke(destObjectName, "resetMessageCounterHistory", null, null);
     
      String html = (String)ServerManagement.invoke(destObjectName, "listMessageCounterHistoryAsHTML", null, null);
     
View Full Code Here

Examples of org.jboss.jms.server.messagecounter.MessageCounter

   {
      List counters = getMessageCounters();

      Collections.sort(counters, new Comparator() {
        public int compare(Object o1, Object o2) {
          MessageCounter m1 = (MessageCounter)o1;
          MessageCounter m2 = (MessageCounter)o2;
          return m1.getDestinationName().compareTo(m2.getDestinationName());
        }
      });

      String ret =
         "<table width=\"100%\" border=\"1\" cellpadding=\"1\" cellspacing=\"1\">"
            + "<tr>"
            + "<th>Type</th>"
            + "<th>Name</th>"
            + "<th>Subscription</th>"
            + "<th>Durable</th>"
            + "<th>Count</th>"
            + "<th>CountDelta</th>"
            + "<th>Depth</th>"
            + "<th>DepthDelta</th>"
            + "<th>Last Add</th>"
            + "</tr>";

      String strNameLast = null;
      String strTypeLast = null;
      String strDestLast = null;

      String destData = "";
      int destCount = 0;

      int countTotal = 0;
      int countDeltaTotal = 0;
      int depthTotal = 0;
      int depthDeltaTotal = 0;

      int i = 0; // define outside of for statement, so variable
      // still exists after for loop, because it is
      // needed during output of last module data string

      Iterator iter = counters.iterator();

      while (iter.hasNext())
      {
         MessageCounter counter = (MessageCounter)iter.next();

         // get counter data
         StringTokenizer tokens = new StringTokenizer(counter.getCounterAsString(), ",");

         String strType = tokens.nextToken();
         String strName = tokens.nextToken();
         String strSub = tokens.nextToken();
         String strDurable = tokens.nextToken();
View Full Code Here

Examples of org.jboss.jms.server.messagecounter.MessageCounter

            {
               //Use override on server peer
               dayLimitToUse = serverPeer.getDefaultMessageCounterHistoryDayLimit();
            }
           
            MessageCounter counter =
               new MessageCounter(counterName, subName, queue, true, true,
                                  dayLimitToUse);
           
            serverPeer.getMessageCounterManager().registerMessageCounter(counterName, counter);   
           
            //Now we need to trigger a delivery - this is because message suckers might have
View Full Code Here

Examples of org.jboss.jms.server.messagecounter.MessageCounter

         {
            //Use override on server peer
            dayLimitToUse = serverPeer.getDefaultMessageCounterHistoryDayLimit();
         }
        
         MessageCounter counter =
            new MessageCounter(counterName, null, queue, false, false,
                               dayLimitToUse);
        
         ((ManagedQueue)destination).setMessageCounter(counter);
                 
         serverPeer.getMessageCounterManager().registerMessageCounter(counterName, counter);
View Full Code Here

Examples of org.jboss.jms.server.messagecounter.MessageCounter

       
         Queue queue = ((ManagedQueue)destination).getQueue();
        
         String counterName = QUEUE_MESSAGECOUNTER_PREFIX + destination.getName();
                 
         MessageCounter counter = serverPeer.getMessageCounterManager().unregisterMessageCounter(counterName);
        
         if (counter == null)
         {
            throw new IllegalStateException("Cannot find counter to unregister " + counterName);
         }
View Full Code Here

Examples of org.jboss.jms.server.messagecounter.MessageCounter

            if (!mDest.isTemporary())
            {
              String counterName = TopicService.SUBSCRIPTION_MESSAGECOUNTER_PREFIX + queueName;
 
              MessageCounter counter = sp.getMessageCounterManager().unregisterMessageCounter(counterName);
 
              if (counter == null)
              {
                 throw new IllegalStateException("Cannot find counter to remove " + counterName);
              }
View Full Code Here

Examples of org.jboss.jms.server.messagecounter.MessageCounter

         postOffice.removeBinding(sub.getName(), sub.isClustered() && postOffice.isClustered());

         String counterName = TopicService.SUBSCRIPTION_MESSAGECOUNTER_PREFIX + sub.getName();

         MessageCounter counter = sp.getMessageCounterManager().unregisterMessageCounter(counterName);

         if (counter == null)
         {
            throw new IllegalStateException("Cannot find counter to remove " + counterName);
         }
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.