activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject svn commit: r1425871 - in /activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker: ./ jmx/
Date Wed, 26 Dec 2012 10:53:41 GMT
Author: rajdavies
Date: Wed Dec 26 10:53:41 2012
New Revision: 1425871

URL: http://svn.apache.org/viewvc?rev=1425871&view=rev
Log:
Fix for https://issues.apache.org/jira/browse/AMQ-4237

Modified:
    activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java
    activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ConnectionView.java
    activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/HealthView.java
    activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/HealthViewMBean.java
    activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java
    activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagedTransportConnection.java
    activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/SubscriptionView.java

Modified: activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java?rev=1425871&r1=1425870&r2=1425871&view=diff
==============================================================================
--- activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java
(original)
+++ activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java
Wed Dec 26 10:53:41 2012
@@ -1178,7 +1178,7 @@ public class BrokerService implements Se
         this.useJmx = useJmx;
     }
 
-    public ObjectName getBrokerObjectName() throws IOException {
+    public ObjectName getBrokerObjectName() throws MalformedObjectNameException {
         if (brokerObjectName == null) {
             brokerObjectName = createBrokerObjectName();
         }
@@ -1998,9 +1998,9 @@ public class BrokerService implements Se
     }
 
     private ObjectName createConnectorObjectName(TransportConnector connector) throws MalformedObjectNameException
{
-        return new ObjectName(getManagementContext().getJmxDomainName() + ":" + "BrokerName="
-                + JMXSupport.encodeObjectNamePart(getBrokerName()) + "," + "Type=Connector,"
+ "ConnectorName="
-                + JMXSupport.encodeObjectNamePart(connector.getName()));
+        String objectNameStr = getBrokerObjectName().toString();
+        objectNameStr += ",connector=clientConnectors,connectorName="+ JMXSupport.encodeObjectNamePart(connector.getName());
+        return new ObjectName(objectNameStr);
     }
 
     protected void registerNetworkConnectorMBean(NetworkConnector connector) throws IOException
{
@@ -2016,17 +2016,17 @@ public class BrokerService implements Se
 
     protected ObjectName createNetworkConnectorObjectName(NetworkConnector connector)
             throws MalformedObjectNameException {
-        return new ObjectName(getManagementContext().getJmxDomainName() + ":" + "BrokerName="
-                + JMXSupport.encodeObjectNamePart(getBrokerName()) + "," + "Type=NetworkConnector,"
-                + "NetworkConnectorName=" + JMXSupport.encodeObjectNamePart(connector.getName()));
+        String objectNameStr = getBrokerObjectName().toString();
+        objectNameStr += ",connector=networkConnectors,networkConnectorName="+ JMXSupport.encodeObjectNamePart(connector.getName());
+        return new ObjectName(objectNameStr);
     }
 
 
     public ObjectName createDuplexNetworkConnectorObjectName(String transport)
             throws MalformedObjectNameException {
-        return new ObjectName(getManagementContext().getJmxDomainName() + ":" + "BrokerName="
-                + JMXSupport.encodeObjectNamePart(getBrokerName()) + "," + "Type=NetworkConnector,"
-                + "NetworkConnectorName=duplex" + JMXSupport.encodeObjectNamePart(transport));
+        String objectNameStr = getBrokerObjectName().toString();
+        objectNameStr += ",connector=duplexNetworkConnectors,networkConnectorName="+ JMXSupport.encodeObjectNamePart(transport);
+        return new ObjectName(objectNameStr);
     }
 
     protected void unregisterNetworkConnectorMBean(NetworkConnector connector) {
@@ -2043,9 +2043,9 @@ public class BrokerService implements Se
     protected void registerProxyConnectorMBean(ProxyConnector connector) throws IOException
{
         ProxyConnectorView view = new ProxyConnectorView(connector);
         try {
-            ObjectName objectName = new ObjectName(getManagementContext().getJmxDomainName()
+ ":" + "BrokerName="
-                    + JMXSupport.encodeObjectNamePart(getBrokerName()) + "," + "Type=ProxyConnector,"
-                    + "ProxyConnectorName=" + JMXSupport.encodeObjectNamePart(connector.getName()));
+            String objectNameStr = getBrokerObjectName().toString();
+            objectNameStr += ",connector=proxyConnectors,proxyConnectorName="+ JMXSupport.encodeObjectNamePart(connector.getName());
+            ObjectName objectName = new ObjectName(objectNameStr);
             AnnotatedMBean.registerMBean(getManagementContext(), view, objectName);
         } catch (Throwable e) {
             throw IOExceptionSupport.create("Broker could not be registered in JMX: " + e.getMessage(),
e);
@@ -2057,9 +2057,9 @@ public class BrokerService implements Se
     protected void registerJmsConnectorMBean(JmsConnector connector) throws IOException {
         JmsConnectorView view = new JmsConnectorView(connector);
         try {
-            ObjectName objectName = new ObjectName(getManagementContext().getJmxDomainName()
+ ":" + "BrokerName="
-                    + JMXSupport.encodeObjectNamePart(getBrokerName()) + "," + "Type=JmsConnector,"
-                    + "JmsConnectorName=" + JMXSupport.encodeObjectNamePart(connector.getName()));
+            String objectNameStr = getBrokerObjectName().toString();
+            objectNameStr += ",connector=jmsConnectors,JmsConnectors="+ JMXSupport.encodeObjectNamePart(connector.getName());
+            ObjectName objectName = new ObjectName(objectNameStr);
             AnnotatedMBean.registerMBean(getManagementContext(), view, objectName);
         } catch (Throwable e) {
             throw IOExceptionSupport.create("Broker could not be registered in JMX: " + e.getMessage(),
e);
@@ -2123,8 +2123,13 @@ public class BrokerService implements Se
     protected Broker createRegionBroker(DestinationInterceptor destinationInterceptor) throws
IOException {
         RegionBroker regionBroker;
         if (isUseJmx()) {
+            try {
             regionBroker = new ManagedRegionBroker(this, getManagementContext(), getBrokerObjectName(),
                     getTaskRunnerFactory(), getConsumerSystemUsage(), destinationFactory,
destinationInterceptor,getScheduler(),getExecutor());
+            }catch(MalformedObjectNameException me){
+                LOG.error("Couldn't create ManagedRegionBroker",me);
+                throw new IOException(me);
+            }
         } else {
             regionBroker = new RegionBroker(this, getTaskRunnerFactory(), getConsumerSystemUsage(),
destinationFactory,
                     destinationInterceptor,getScheduler(),getExecutor());
@@ -2173,10 +2178,10 @@ public class BrokerService implements Se
             if (isUseJmx()) {
                 JobSchedulerViewMBean view = new JobSchedulerView(sb.getJobScheduler());
                 try {
-                    ObjectName objectName = new ObjectName(getManagementContext().getJmxDomainName()
+ ":"
-                            + "BrokerName=" + JMXSupport.encodeObjectNamePart(getBrokerName())
+ ","
-                            + "Type=jobScheduler," + "jobSchedulerName=JMS");
 
+                    String objectNameStr = getBrokerObjectName().toString();
+                    objectNameStr += ",service=JobScheduler,name=JMS";
+                    ObjectName objectName = new ObjectName(objectNameStr);
                     AnnotatedMBean.registerMBean(getManagementContext(), view, objectName);
                     this.adminView.setJMSJobScheduler(objectName);
                 } catch (Throwable e) {
@@ -2190,10 +2195,9 @@ public class BrokerService implements Se
         if (isUseJmx()) {
             HealthViewMBean statusView = new HealthView((ManagedRegionBroker)getRegionBroker());
             try {
-                ObjectName objectName = new ObjectName(getManagementContext().getJmxDomainName()
+ ":"
-                        + "BrokerName=" + JMXSupport.encodeObjectNamePart(getBrokerName())
+ ","
-                        + "Type=Health");
-
+                String objectNameStr = getBrokerObjectName().toString();
+                objectNameStr += ",service=Health";
+                ObjectName objectName = new ObjectName(objectNameStr);
                 AnnotatedMBean.registerMBean(getManagementContext(), statusView, objectName);
             } catch (Throwable e) {
                 throw IOExceptionSupport.create("Status MBean could not be registered in
JMX: "
@@ -2243,13 +2247,10 @@ public class BrokerService implements Se
         }
     }
 
-    protected ObjectName createBrokerObjectName() throws IOException {
-        try {
-            return new ObjectName(getManagementContext().getJmxDomainName() + ":" + "BrokerName="
-                    + JMXSupport.encodeObjectNamePart(getBrokerName()) + "," + "Type=Broker");
-        } catch (Throwable e) {
-            throw IOExceptionSupport.create("Invalid JMX broker name: " + brokerName, e);
-        }
+    protected ObjectName createBrokerObjectName() throws MalformedObjectNameException  {
+        String objectNameStr = getManagementContext().getJmxDomainName() + ":type=Broker,brokerName=";
+        objectNameStr += JMXSupport.encodeObjectNamePart(getBrokerName());
+        return new ObjectName(objectNameStr);
     }
 
     protected TransportConnector createTransportConnector(URI brokerURI) throws Exception
{

Modified: activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ConnectionView.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ConnectionView.java?rev=1425871&r1=1425870&r2=1425871&view=diff
==============================================================================
--- activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ConnectionView.java
(original)
+++ activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ConnectionView.java
Wed Dec 26 10:53:41 2012
@@ -149,9 +149,9 @@ public class ConnectionView implements C
 
     private ObjectName createConsumerQueury(String clientId) throws IOException {
         try {
-            return new ObjectName(managementContext.getJmxDomainName() + ":" + "BrokerName=*,"
-                                  + "Type=Subscription,persistentMode=*,"
+            return new ObjectName(managementContext.getJmxDomainName() + ":type=Broker,brokerName=*,"
                                   + "destinationType=*,destinationName=*,"
+                                  + "endpoint=Consumer,"
                                   + "clientId=" + JMXSupport.encodeObjectNamePart(clientId)
+ ","
                                   + "consumerId=*");
         } catch (Throwable e) {
@@ -161,11 +161,11 @@ public class ConnectionView implements C
 
     private ObjectName createProducerQueury(String clientId) throws IOException {
         try {
-            return new ObjectName(managementContext.getJmxDomainName() + ":" + "BrokerName=*,"
-                                  + "Type=Producer,"
-                                  + "destinationType=*,destinationName=*,"
-                                  + "clientId=" + JMXSupport.encodeObjectNamePart(clientId)
+ ","
-                                  + "producerId=*");
+            return new ObjectName(managementContext.getJmxDomainName() + ":type=Broker,brokerName=*,"
+                    + "destinationType=*,destinationName=*,"
+                    + "endpoint=Producer,"
+                    + "clientId=" + JMXSupport.encodeObjectNamePart(clientId) + ","
+                    + "producerId=*");
         } catch (Throwable e) {
             throw IOExceptionSupport.create(e);
         }

Modified: activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/HealthView.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/HealthView.java?rev=1425871&r1=1425870&r2=1425871&view=diff
==============================================================================
--- activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/HealthView.java
(original)
+++ activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/HealthView.java
Wed Dec 26 10:53:41 2012
@@ -35,6 +35,7 @@ import org.apache.activemq.usage.SystemU
 public class HealthView implements HealthViewMBean {
 
     ManagedRegionBroker broker;
+    String currentState = "Good";
 
     public HealthView(ManagedRegionBroker broker) {
         this.broker = broker;
@@ -172,7 +173,24 @@ public class HealthView implements Healt
             }
         }
 
+    if (answer != null && !answer.isEmpty()){
+         this.currentState = "Feeling Ill {";
+        for (HealthStatus hs: answer){
+            currentState += hs + " , ";
+        }
+        currentState += " }";
+    } else{
+        this.currentState="Good";
+    }
         return answer;
     }
 
+    /**
+     * @return String representation of the current Broker state
+     */
+    @Override
+    public String getCurrentStatus() {
+        return this.currentState;
+    }
+
 }

Modified: activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/HealthViewMBean.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/HealthViewMBean.java?rev=1425871&r1=1425870&r2=1425871&view=diff
==============================================================================
--- activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/HealthViewMBean.java
(original)
+++ activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/HealthViewMBean.java
Wed Dec 26 10:53:41 2012
@@ -33,5 +33,12 @@ public interface HealthViewMBean {
      *
      * If in doubt, please use the {@link #status()} method instead!
      */
+    @MBeanInfo("List of warnings and errors about the current health of the Broker - empty
list is Good!")
     List<HealthStatus> healthList() throws Exception;
+
+    /**
+     * @return  String representation of the current Broker state
+     */
+    @MBeanInfo("String representation of current Broker state")
+    String getCurrentStatus();
 }

Modified: activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java?rev=1425871&r1=1425870&r2=1425871&view=diff
==============================================================================
--- activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java
(original)
+++ activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java
Wed Dec 26 10:53:41 2012
@@ -40,23 +40,12 @@ import javax.management.openmbean.OpenDa
 import javax.management.openmbean.TabularData;
 import javax.management.openmbean.TabularDataSupport;
 import javax.management.openmbean.TabularType;
-
 import org.apache.activemq.broker.Broker;
 import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.broker.ConnectionContext;
 import org.apache.activemq.broker.ProducerBrokerExchange;
 import org.apache.activemq.broker.jmx.OpenTypeSupport.OpenTypeFactory;
-import org.apache.activemq.broker.region.Destination;
-import org.apache.activemq.broker.region.DestinationFactory;
-import org.apache.activemq.broker.region.DestinationFactoryImpl;
-import org.apache.activemq.broker.region.DestinationInterceptor;
-import org.apache.activemq.broker.region.Queue;
-import org.apache.activemq.broker.region.Region;
-import org.apache.activemq.broker.region.RegionBroker;
-import org.apache.activemq.broker.region.Subscription;
-import org.apache.activemq.broker.region.Topic;
-import org.apache.activemq.broker.region.TopicRegion;
-import org.apache.activemq.broker.region.TopicSubscription;
+import org.apache.activemq.broker.region.*;
 import org.apache.activemq.broker.region.policy.AbortSlowConsumerStrategy;
 import org.apache.activemq.command.ActiveMQDestination;
 import org.apache.activemq.command.ActiveMQMessage;
@@ -228,27 +217,15 @@ public class ManagedRegionBroker extends
     }
 
     public static String getSubscriptionObjectName(ConsumerInfo info, String connectionClientId,
ObjectName brokerJmxObjectName) {
-        Hashtable<String, String> map = brokerJmxObjectName.getKeyPropertyList();
-        String brokerDomain = brokerJmxObjectName.getDomain();
-        String objectNameStr = brokerDomain + ":" + "BrokerName=" + map.get("BrokerName")
+ ",Type=Subscription,";
-        String destinationType = "destinationType=" + info.getDestination().getDestinationTypeAsString();
-        String destinationName = "destinationName=" + JMXSupport.encodeObjectNamePart(info.getDestination().getPhysicalName());
-        String clientId = "clientId=" + JMXSupport.encodeObjectNamePart(connectionClientId);
-        String persistentMode = "persistentMode=";
-        String consumerId = "";
-        if (info.isDurable()) {
-            persistentMode += "Durable,subscriptionID=" + JMXSupport.encodeObjectNamePart(info.getSubscriptionName());
+        String objectNameStr = brokerJmxObjectName.toString();
+        objectNameStr += getDestinationType(info.getDestination()) + ",endpoint=Consumer";
+        objectNameStr += ",clientId=" +  JMXSupport.encodeObjectNamePart(connectionClientId);
+        objectNameStr += ",consumerId=";
+        if (info.isDurable()){
+            objectNameStr += "Durable(" +  JMXSupport.encodeObjectNamePart(connectionClientId
+ ":" + info.getSubscriptionName()) +")";
         } else {
-            persistentMode += "Non-Durable";
-            if (info.getConsumerId() != null) {
-                consumerId = ",consumerId=" + JMXSupport.encodeObjectNamePart(info.getConsumerId().toString());
-            }
+            objectNameStr += JMXSupport.encodeObjectNamePart(info.getConsumerId().toString());
         }
-        objectNameStr += persistentMode + ",";
-        objectNameStr += destinationType + ",";
-        objectNameStr += destinationName + ",";
-        objectNameStr += clientId;
-        objectNameStr += consumerId;
         return objectNameStr;
     }
 
@@ -698,39 +675,33 @@ public class ManagedRegionBroker extends
         this.contextBroker = contextBroker;
     }
 
-    protected ObjectName createObjectName(ActiveMQDestination destName) throws MalformedObjectNameException
{
+    protected ObjectName createObjectName(ActiveMQDestination destination) throws MalformedObjectNameException
{
         // Build the object name for the destination
-        Hashtable<String, String> map = brokerObjectName.getKeyPropertyList();
-        ObjectName objectName = new ObjectName(brokerObjectName.getDomain() + ":" + "BrokerName="
+ map.get("BrokerName") + "," + "Type="
-                                               + JMXSupport.encodeObjectNamePart(destName.getDestinationTypeAsString())
+ "," + "Destination="
-                                               + JMXSupport.encodeObjectNamePart(destName.getPhysicalName()));
-        return objectName;
+        String objectNameStr = brokerObjectName.toString();
+        objectNameStr += getDestinationType(destination);
+        return new ObjectName(objectNameStr);
     }
 
-    protected ObjectName createObjectName(ProducerInfo producerInfo, String connectionClientId)
throws MalformedObjectNameException {
-        // Build the object name for the producer info
-        Hashtable<String, String> map = brokerObjectName.getKeyPropertyList();
+    protected static String getDestinationType(ActiveMQDestination destination){
+        String result = "";
+        if (destination != null){
+            result = ",destinationType="+ JMXSupport.encodeObjectNamePart(destination.getDestinationTypeAsString())
+  ",destinationName=" + JMXSupport.encodeObjectNamePart(destination.getPhysicalName());
+        }
+        return result;
+    }
 
-        String destinationType = "destinationType=";
-        String destinationName = "destinationName=";
+    protected ObjectName createObjectName(ProducerInfo producerInfo, String connectionClientId)
throws MalformedObjectNameException {
+        String objectNameStr = brokerObjectName.toString();
 
         if (producerInfo.getDestination() == null) {
-            destinationType += "Dynamic";
-            destinationName = null;
+            objectNameStr += ",endpoint=dynamicProducer";
         } else {
-            destinationType += producerInfo.getDestination().getDestinationTypeAsString();
-            destinationName += JMXSupport.encodeObjectNamePart(producerInfo.getDestination().getPhysicalName());
+            objectNameStr += getDestinationType(producerInfo.getDestination()) + ",endpoint=Producer";
         }
 
-        String clientId = "clientId=" + JMXSupport.encodeObjectNamePart(connectionClientId);
-        String producerId = "producerId=" + JMXSupport.encodeObjectNamePart(producerInfo.getProducerId().toString());
-
-        ObjectName objectName = new ObjectName(brokerObjectName.getDomain() + ":" + "BrokerName="
+ map.get("BrokerName") + ","
-                                               + "Type=Producer" + ","
-                                               + destinationType + ","
-                                               + (destinationName != null ? destinationName
+ "," : "")
-                                               + clientId + "," + producerId);
-        return objectName;
+        objectNameStr += ",clientId=" + JMXSupport.encodeObjectNamePart(connectionClientId);
+        objectNameStr += ",producerId=" + JMXSupport.encodeObjectNamePart(producerInfo.getProducerId().toString());
+        return new ObjectName(objectNameStr);
     }
 
     public ObjectName registerSlowConsumerStrategy(AbortSlowConsumerStrategy strategy) throws
MalformedObjectNameException {
@@ -750,9 +721,8 @@ public class ManagedRegionBroker extends
     }
 
     protected ObjectName createObjectName(XATransaction transaction) throws MalformedObjectNameException
{
-        Hashtable<String, String> map = brokerObjectName.getKeyPropertyList();
-        ObjectName objectName = new ObjectName(brokerObjectName.getDomain() + ":" + "BrokerName="
+ map.get("BrokerName")
-                                               + "," + "Type=RecoveredXaTransaction"
+        ObjectName objectName = new ObjectName(brokerObjectName.toString()
+                                               + "," + "transactionType=RecoveredXaTransaction"
                                                + "," + "Xid="
                                                + JMXSupport.encodeObjectNamePart(transaction.getTransactionId().toString()));
         return objectName;
@@ -789,9 +759,10 @@ public class ManagedRegionBroker extends
     }
 
     private ObjectName createObjectName(AbortSlowConsumerStrategy strategy) throws MalformedObjectNameException{
+        String objectNameStr = this.brokerObjectName.toString();
+        objectNameStr += "Service=SlowConsumerStrategy,InstanceName="+ JMXSupport.encodeObjectNamePart(strategy.getName());
         Hashtable<String, String> map = brokerObjectName.getKeyPropertyList();
-        ObjectName objectName = new ObjectName(brokerObjectName.getDomain() + ":" + "BrokerName="
+ map.get("BrokerName") + ","
-                            + "Type=SlowConsumerStrategy," + "InstanceName=" + JMXSupport.encodeObjectNamePart(strategy.getName()));
+        ObjectName objectName = new ObjectName(objectNameStr);
         return objectName;
     }
 

Modified: activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagedTransportConnection.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagedTransportConnection.java?rev=1425871&r1=1425870&r2=1425871&view=diff
==============================================================================
--- activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagedTransportConnection.java
(original)
+++ activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagedTransportConnection.java
Wed Dec 26 10:53:41 2012
@@ -17,10 +17,8 @@
 package org.apache.activemq.broker.jmx;
 
 import java.io.IOException;
-import java.util.Hashtable;
 
 import javax.management.ObjectName;
-
 import org.apache.activemq.broker.Broker;
 import org.apache.activemq.broker.TransportConnection;
 import org.apache.activemq.broker.TransportConnector;
@@ -116,27 +114,21 @@ public class ManagedTransportConnection 
     }
 
     protected ObjectName createByAddressObjectName(String type, String value) throws IOException
{
-        Hashtable<String, String> map = connectorName.getKeyPropertyList();
         try {
-            return new ObjectName(connectorName.getDomain() + ":" + "BrokerName="
-                                  + JMXSupport.encodeObjectNamePart((String)map.get("BrokerName"))
+ ","
-                                  + "Type=Connection," + "ConnectorName="
-                                  + JMXSupport.encodeObjectNamePart((String)map.get("ConnectorName"))
+ ","
-                                  + "ViewType=" + JMXSupport.encodeObjectNamePart(type) +
"," + "Name="
-                                  + JMXSupport.encodeObjectNamePart(value));
+            String objectNameStr = connectorName.toString();
+            objectNameStr += ",connectionViewType="   + JMXSupport.encodeObjectNamePart(type);
+            objectNameStr += ",connectionName="+JMXSupport.encodeObjectNamePart(value);
+            return new ObjectName(objectNameStr);
         } catch (Throwable e) {
             throw IOExceptionSupport.create(e);
         }
     }
 
     protected ObjectName createByClientIdObjectName(String value) throws IOException {
-        Hashtable<String, String> map = connectorName.getKeyPropertyList();
         try {
-            return new ObjectName(connectorName.getDomain() + ":" + "BrokerName="
-                                  + JMXSupport.encodeObjectNamePart((String)map.get("BrokerName"))
+ ","
-                                  + "Type=Connection," + "ConnectorName="
-                                  + JMXSupport.encodeObjectNamePart((String)map.get("ConnectorName"))
+ ","
-                                  + "Connection=" + JMXSupport.encodeObjectNamePart(value));
+            String objectNameStr = connectorName.toString();
+            objectNameStr += ",connectionName="+JMXSupport.encodeObjectNamePart(value);
+            return new ObjectName(objectNameStr);
         } catch (Throwable e) {
             throw IOExceptionSupport.create(e);
         }

Modified: activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/SubscriptionView.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/SubscriptionView.java?rev=1425871&r1=1425870&r2=1425871&view=diff
==============================================================================
--- activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/SubscriptionView.java
(original)
+++ activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/SubscriptionView.java
Wed Dec 26 10:53:41 2012
@@ -74,7 +74,7 @@ public class SubscriptionView implements
                 if (managementCtx != null) {
 
                     try {
-                        ObjectName query = createConnectionQueury(managementCtx, service.getBrokerName());
+                        ObjectName query = createConnectionQuery(managementCtx, service.getBrokerName());
                         Set<ObjectName> names = managementCtx.queryNames(query, null);
                         if (names.size() == 1) {
                             result = names.iterator().next();
@@ -87,12 +87,12 @@ public class SubscriptionView implements
         return result;
     }
 
-    private ObjectName createConnectionQueury(ManagementContext ctx, String brokerName) throws
IOException {
+    private ObjectName createConnectionQuery(ManagementContext ctx, String brokerName) throws
IOException {
         try {
-            return new ObjectName(ctx.getJmxDomainName() + ":" + "BrokerName="
+            return new ObjectName(ctx.getJmxDomainName() + ":type=Broker,brokerName="
                                   + JMXSupport.encodeObjectNamePart(brokerName) + ","
-                                  + "Type=Connection," + "ConnectorName=*,"
-                                  + "Connection=" + JMXSupport.encodeObjectNamePart(clientId));
+                                  + "connector=*," + "connectorName=*,"
+                                  + "connectionName=" + JMXSupport.encodeObjectNamePart(clientId));
         } catch (Throwable e) {
             throw IOExceptionSupport.create(e);
         }



Mime
View raw message