activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r1406210 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/broker/jmx/DestinationView.java main/java/org/apache/activemq/broker/jmx/DestinationViewMBean.java test/java/org/apache/activemq/broker/jmx/MBeanTest.java
Date Tue, 06 Nov 2012 16:30:31 GMT
Author: gtully
Date: Tue Nov  6 16:30:31 2012
New Revision: 1406210

URL: http://svn.apache.org/viewvc?rev=1406210&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-4162 - visibility on destination query string options,
destinationView.options - useful for user metadata about the destination

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/DestinationView.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/DestinationViewMBean.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/DestinationView.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/DestinationView.java?rev=1406210&r1=1406209&r2=1406210&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/DestinationView.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/DestinationView.java
Tue Nov  6 16:30:31 2012
@@ -17,6 +17,7 @@
 package org.apache.activemq.broker.jmx;
 
 import java.io.IOException;
+import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Iterator;
@@ -50,6 +51,7 @@ import org.apache.activemq.command.Messa
 import org.apache.activemq.filter.BooleanExpression;
 import org.apache.activemq.filter.MessageEvaluationContext;
 import org.apache.activemq.selector.SelectorParser;
+import org.apache.activemq.util.URISupport;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -413,4 +415,15 @@ public class DestinationView implements 
         return result;
     }
 
+    public String getOptions() {
+        Map<String, String> options = destination.getActiveMQDestination().getOptions();
+        String optionsString = "";
+        try {
+            if (options != null) {
+                optionsString = URISupport.createQueryString(options);
+            }
+        } catch (URISyntaxException ignored) {}
+        return optionsString;
+    }
+
 }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/DestinationViewMBean.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/DestinationViewMBean.java?rev=1406210&r1=1406209&r2=1406210&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/DestinationViewMBean.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/DestinationViewMBean.java
Tue Nov  6 16:30:31 2012
@@ -359,4 +359,10 @@ public interface DestinationViewMBean {
     @MBeanInfo("returns the optional slowConsumer handler MBeans for this destination")
     ObjectName getSlowConsumerStrategy() throws IOException, MalformedObjectNameException;
 
+    /**
+     * @return A string of destination options, name value pairs as URL queryString.
+     */
+    @MBeanInfo("returns the destination options, name value pairs as URL queryString")
+    String getOptions();
+
 }

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java?rev=1406210&r1=1406209&r2=1406210&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java
Tue Nov  6 16:30:31 2012
@@ -55,6 +55,7 @@ import org.apache.activemq.command.Activ
 import org.apache.activemq.command.ActiveMQQueue;
 import org.apache.activemq.command.ActiveMQTempQueue;
 import org.apache.activemq.util.JMXSupport;
+import org.apache.activemq.util.URISupport;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -76,6 +77,7 @@ public class MBeanTest extends EmbeddedB
     protected boolean transacted;
     protected int authMode = Session.AUTO_ACKNOWLEDGE;
     protected static final int MESSAGE_COUNT = 2*BaseDestination.MAX_PAGE_SIZE;
+    final static String QUEUE_WITH_OPTIONS = "QueueWithOptions";
 
     /**
      * When you run this test case from the command line it will pause before
@@ -719,6 +721,9 @@ public class MBeanTest extends EmbeddedB
         policyMap.setDefaultEntry(defaultEntry);
         answer.setDestinationPolicy(policyMap);
 
+        // allow options to be visible via jmx
+        answer.setDestinations(new ActiveMQDestination[]{new ActiveMQQueue(QUEUE_WITH_OPTIONS
+ "?topQueue=true&hasOptions=2")});
+
         answer.addConnector(bindAddress);
         return answer;
     }
@@ -895,6 +900,25 @@ public class MBeanTest extends EmbeddedB
         assertTrue("dest has some memory usage", queue.getMemoryPercentUsage() > 0);
     }
 
+    public void testDestinationOptionsAreVisible() throws Exception {
+        ObjectName queueViewMBeanName = assertRegisteredObjectName(domain + ":Type=Queue,Destination="
+ QUEUE_WITH_OPTIONS + ",BrokerName=localhost");
+
+        QueueViewMBean queue = (QueueViewMBean)MBeanServerInvocationHandler.newProxyInstance(mbeanServer,
queueViewMBeanName, QueueViewMBean.class, true);
+
+        assertEquals("name match", QUEUE_WITH_OPTIONS, queue.getName());
+
+        String options = queue.getOptions();
+        LOG.info("Got options: " + options);
+
+        Map<String, String> optionsMap = URISupport.parseQuery(options);
+        assertEquals("got a map", 2, optionsMap.size());
+        assertTrue("matches our options", optionsMap.containsKey("hasOptions"));
+        assertTrue("matches our options", optionsMap.containsKey("topQueue"));
+
+        assertTrue("matches our options", optionsMap.containsValue("true"));
+        assertTrue("matches our options", optionsMap.containsValue("2"));
+    }
+
     public void testSubscriptionViewToConnectionMBean() throws Exception {
 
         connection = connectionFactory.createConnection("admin", "admin");



Mime
View raw message