activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject svn commit: r463233 - /incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java
Date Thu, 12 Oct 2006 12:43:43 GMT
Author: rajdavies
Date: Thu Oct 12 05:43:42 2006
New Revision: 463233

URL: http://svn.apache.org/viewvc?view=rev&rev=463233
Log:
Subscribers shout have unique ObjectNames - so use the ConsumerId
as part of the object name - unless its a durable subscriber.
Currently, we weren't allowing more than one consumer from the same 
client to be registered

Modified:
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java?view=diff&rev=463233&r1=463232&r2=463233
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java
Thu Oct 12 05:43:42 2006
@@ -171,42 +171,48 @@
         }
     }
 
-    public ObjectName registerSubscription(ConnectionContext context, Subscription sub) {
-        Hashtable map = brokerObjectName.getKeyPropertyList();
-        String persistentMode = "";
-        String destinationType = "";
-        String destinationName = "";
-        String clientID = "";
-        SubscriptionKey key = new SubscriptionKey(context.getClientId(), sub.getConsumerInfo().getSubcriptionName());
-        
-        if (sub.getConsumerInfo().isDurable()) {
-            persistentMode = "Durable, subscriptionID=" + JMXSupport.encodeObjectNamePart(sub.getConsumerInfo().getSubcriptionName());
-        } else {
-            persistentMode = "Non-Durable";
+    public ObjectName registerSubscription(ConnectionContext context,Subscription sub){
+        Hashtable map=brokerObjectName.getKeyPropertyList();
+        String objectNameStr=brokerObjectName.getDomain()+":"+"BrokerName="+map.get("BrokerName")+",Type=Subscription,";
+        String destinationType="destinationType="+sub.getConsumerInfo().getDestination().getDestinationTypeAsString();
+        String destinationName="destinationName="
+                +JMXSupport.encodeObjectNamePart(sub.getConsumerInfo().getDestination().getPhysicalName());
+        String clientId="clientId="+JMXSupport.encodeObjectNamePart(context.getClientId());
+        String persistentMode="persistentMode=";
+        String consumerId="";
+        SubscriptionKey key=new SubscriptionKey(context.getClientId(),sub.getConsumerInfo().getSubcriptionName());
+        if(sub.getConsumerInfo().isDurable()){
+            persistentMode+="Durable, subscriptionID="
+                    +JMXSupport.encodeObjectNamePart(sub.getConsumerInfo().getSubcriptionName());
+        }else{
+            persistentMode+="Non-Durable";
+            if(sub.getConsumerInfo()!=null&&sub.getConsumerInfo().getConsumerId()!=null){
+                consumerId=",consumerId="
+                        +JMXSupport.encodeObjectNamePart(sub.getConsumerInfo().getConsumerId().toString());
+            }
         }
-
-        destinationType = sub.getConsumerInfo().getDestination().getDestinationTypeAsString();
-        destinationName = sub.getConsumerInfo().getDestination().getPhysicalName();
-        clientID = context.getClientId();
-
-        try {
-        	ObjectName objectName = new ObjectName(brokerObjectName.getDomain() + ":" + "BrokerName="
+ map.get("BrokerName")
-                        + "," + "Type=Subscription, persistentMode=" + persistentMode + ",
destinationType=" + destinationType + ", destinationName=" + JMXSupport.encodeObjectNamePart(destinationName)
+ ", clientID=" + JMXSupport.encodeObjectNamePart(clientID) + "");
+        objectNameStr+=persistentMode+",";
+        objectNameStr+=destinationType+",";
+        objectNameStr+=destinationName+",";
+        objectNameStr+=clientId;
+        objectNameStr+=consumerId;
+        try{
+            ObjectName objectName=new ObjectName(objectNameStr);
             SubscriptionView view;
-            if (sub.getConsumerInfo().isDurable()) {
-                view = new DurableSubscriptionView(this, context.getClientId(), sub);
-            } else {
-                if (sub instanceof TopicSubscription) {
-                    view = new TopicSubscriptionView(context.getClientId(), (TopicSubscription)
sub);
-                } else {
-                    view = new SubscriptionView(context.getClientId(), sub);
+            if(sub.getConsumerInfo().isDurable()){
+                view=new DurableSubscriptionView(this,context.getClientId(),sub);
+            }else{
+                if(sub instanceof TopicSubscription){
+                    view=new TopicSubscriptionView(context.getClientId(),(TopicSubscription)sub);
+                }else{
+                    view=new SubscriptionView(context.getClientId(),sub);
                 }
             }
-            registerSubscription(objectName, sub.getConsumerInfo(), key, view);
-            subscriptionMap.put(sub, objectName);
+            registerSubscription(objectName,sub.getConsumerInfo(),key,view);
+            subscriptionMap.put(sub,objectName);
             return objectName;
-        } catch (Exception e) {
-            log.error("Failed to register subscription " + sub, e);
+        }catch(Exception e){
+            log.error("Failed to register subscription "+sub,e);
             return null;
         }
     }



Mime
View raw message