Author: robbie
Date: Mon Aug 10 15:01:01 2009
New Revision: 802819

URL: http://svn.apache.org/viewvc?rev=802819&view=rev
Log:
QPID-2018: Updated AMQQueueMBean to make use of the AMQQueue clearQueue return 
value to report the number of messages deleted. Updated management console 
accordingly, also indicating that it is only non-acquired messaes that are 
cleared

Modified:
    
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueMBean.java
    
qpid/trunk/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ManagedQueue.java
    
qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/queue/QueueOperationsTabControl.java

Modified: 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueMBean.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueMBean.java?rev=802819&r1=802818&r2=802819&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueMBean.java
 (original)
+++ 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueMBean.java
 Mon Aug 10 15:01:01 2009
@@ -307,13 +307,16 @@
     }
 
     /**
+     * Clears the queue of non-acquired messages
+     * 
+     * @return the number of messages deleted
      * @see AMQQueue#clearQueue
      */
-    public void clearQueue() throws JMException
+    public Long clearQueue() throws JMException
     {
         try
         {
-            _queue.clearQueue(_storeContext);
+            return _queue.clearQueue(_storeContext);
         }
         catch (AMQException ex)
         {

Modified: 
qpid/trunk/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ManagedQueue.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ManagedQueue.java?rev=802819&r1=802818&r2=802819&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ManagedQueue.java
 (original)
+++ 
qpid/trunk/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ManagedQueue.java
 Mon Aug 10 15:01:01 2009
@@ -291,14 +291,18 @@
     void deleteMessageFromTop() throws IOException, JMException;
 
     /**
-     * Clears the queue by deleting all the undelivered messages from the 
queue.
+     * Clears the queue by deleting all the messages from the queue that have 
not been acquired by consumers"
+     * 
+     * Since Qpid JMX API 1.3 this returns the number of messages deleted. 
Prior to this, the return type was void.
+     * @return the number of messages deleted
      * @throws IOException
      * @throws JMException
      */
     @MBeanOperation(name="clearQueue",
-                    description="Clears the queue by deleting all the 
undelivered messages from the queue",
+                    description="Clears the queue by deleting all the messages 
from the queue " +
+                               "that have not been acquired by consumers",
                     impact= MBeanOperationInfo.ACTION)
-    void clearQueue() throws IOException, JMException;
+    Long clearQueue() throws IOException, JMException;
 
     /**
      * Moves the messages in given range of message Ids to given Queue. 
QPID-170

Modified: 
qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/queue/QueueOperationsTabControl.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/queue/QueueOperationsTabControl.java?rev=802819&r1=802818&r2=802819&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/queue/QueueOperationsTabControl.java
 (original)
+++ 
qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/queue/QueueOperationsTabControl.java
 Mon Aug 10 15:01:01 2009
@@ -457,8 +457,21 @@
                 {
                     try
                     {
-                        _qmb.clearQueue();
-                        ViewUtility.operationResultFeedback(null, "Queue 
cleared", null);
+                        if(_ApiVersion.greaterThanOrEqualTo(1, 3))
+                        {
+                            //Qpid JMX API 1.3+, returns the number of 
messages deleted
+                            Long numDeleted = _qmb.clearQueue();
+                            String message = "Queue cleared of " + numDeleted 
+ 
+                                             " non-acquired message" + 
(numDeleted == 1 ? "": "s");
+                            
+                            ViewUtility.operationResultFeedback(null, message, 
null);
+                        }
+                        else
+                        {
+                            //Qpid JMX API 1.2 or below, void return
+                            _qmb.clearQueue();
+                            ViewUtility.operationResultFeedback(null, "Queue 
cleared of non-acquired messages", null);
+                        }
                     }
                     catch (Exception e2)
                     {



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscr...@qpid.apache.org

Reply via email to