mirror of https://github.com/apache/activemq.git
https://issues.apache.org/jira/browse/AMQ-4162 - visibility on destination query string options, destinationView.options - useful for user metadata about the destination
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1406210 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
19622d36a6
commit
7410257c2f
|
@ -17,6 +17,7 @@
|
||||||
package org.apache.activemq.broker.jmx;
|
package org.apache.activemq.broker.jmx;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -50,6 +51,7 @@ import org.apache.activemq.command.Message;
|
||||||
import org.apache.activemq.filter.BooleanExpression;
|
import org.apache.activemq.filter.BooleanExpression;
|
||||||
import org.apache.activemq.filter.MessageEvaluationContext;
|
import org.apache.activemq.filter.MessageEvaluationContext;
|
||||||
import org.apache.activemq.selector.SelectorParser;
|
import org.apache.activemq.selector.SelectorParser;
|
||||||
|
import org.apache.activemq.util.URISupport;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -413,4 +415,15 @@ public class DestinationView implements DestinationViewMBean {
|
||||||
return result;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -359,4 +359,10 @@ public interface DestinationViewMBean {
|
||||||
@MBeanInfo("returns the optional slowConsumer handler MBeans for this destination")
|
@MBeanInfo("returns the optional slowConsumer handler MBeans for this destination")
|
||||||
ObjectName getSlowConsumerStrategy() throws IOException, MalformedObjectNameException;
|
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();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,7 @@ import org.apache.activemq.command.ActiveMQDestination;
|
||||||
import org.apache.activemq.command.ActiveMQQueue;
|
import org.apache.activemq.command.ActiveMQQueue;
|
||||||
import org.apache.activemq.command.ActiveMQTempQueue;
|
import org.apache.activemq.command.ActiveMQTempQueue;
|
||||||
import org.apache.activemq.util.JMXSupport;
|
import org.apache.activemq.util.JMXSupport;
|
||||||
|
import org.apache.activemq.util.URISupport;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -76,6 +77,7 @@ public class MBeanTest extends EmbeddedBrokerTestSupport {
|
||||||
protected boolean transacted;
|
protected boolean transacted;
|
||||||
protected int authMode = Session.AUTO_ACKNOWLEDGE;
|
protected int authMode = Session.AUTO_ACKNOWLEDGE;
|
||||||
protected static final int MESSAGE_COUNT = 2*BaseDestination.MAX_PAGE_SIZE;
|
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
|
* When you run this test case from the command line it will pause before
|
||||||
|
@ -719,6 +721,9 @@ public class MBeanTest extends EmbeddedBrokerTestSupport {
|
||||||
policyMap.setDefaultEntry(defaultEntry);
|
policyMap.setDefaultEntry(defaultEntry);
|
||||||
answer.setDestinationPolicy(policyMap);
|
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);
|
answer.addConnector(bindAddress);
|
||||||
return answer;
|
return answer;
|
||||||
}
|
}
|
||||||
|
@ -895,6 +900,25 @@ public class MBeanTest extends EmbeddedBrokerTestSupport {
|
||||||
assertTrue("dest has some memory usage", queue.getMemoryPercentUsage() > 0);
|
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 {
|
public void testSubscriptionViewToConnectionMBean() throws Exception {
|
||||||
|
|
||||||
connection = connectionFactory.createConnection("admin", "admin");
|
connection = connectionFactory.createConnection("admin", "admin");
|
||||||
|
|
Loading…
Reference in New Issue