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

git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@463233 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Davies 2006-10-12 12:43:42 +00:00
parent 3c9a89ac1a
commit a20de10f4a
1 changed files with 37 additions and 31 deletions

View File

@ -173,25 +173,31 @@ public class ManagedRegionBroker extends RegionBroker {
public ObjectName registerSubscription(ConnectionContext context,Subscription sub){ public ObjectName registerSubscription(ConnectionContext context,Subscription sub){
Hashtable map=brokerObjectName.getKeyPropertyList(); Hashtable map=brokerObjectName.getKeyPropertyList();
String persistentMode = ""; String objectNameStr=brokerObjectName.getDomain()+":"+"BrokerName="+map.get("BrokerName")+",Type=Subscription,";
String destinationType = ""; String destinationType="destinationType="+sub.getConsumerInfo().getDestination().getDestinationTypeAsString();
String destinationName = ""; String destinationName="destinationName="
String clientID = ""; +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()); SubscriptionKey key=new SubscriptionKey(context.getClientId(),sub.getConsumerInfo().getSubcriptionName());
if(sub.getConsumerInfo().isDurable()){ if(sub.getConsumerInfo().isDurable()){
persistentMode = "Durable, subscriptionID=" + JMXSupport.encodeObjectNamePart(sub.getConsumerInfo().getSubcriptionName()); persistentMode+="Durable, subscriptionID="
+JMXSupport.encodeObjectNamePart(sub.getConsumerInfo().getSubcriptionName());
}else{ }else{
persistentMode = "Non-Durable"; persistentMode+="Non-Durable";
if(sub.getConsumerInfo()!=null&&sub.getConsumerInfo().getConsumerId()!=null){
consumerId=",consumerId="
+JMXSupport.encodeObjectNamePart(sub.getConsumerInfo().getConsumerId().toString());
} }
}
destinationType = sub.getConsumerInfo().getDestination().getDestinationTypeAsString(); objectNameStr+=persistentMode+",";
destinationName = sub.getConsumerInfo().getDestination().getPhysicalName(); objectNameStr+=destinationType+",";
clientID = context.getClientId(); objectNameStr+=destinationName+",";
objectNameStr+=clientId;
objectNameStr+=consumerId;
try{ try{
ObjectName objectName = new ObjectName(brokerObjectName.getDomain() + ":" + "BrokerName=" + map.get("BrokerName") ObjectName objectName=new ObjectName(objectNameStr);
+ "," + "Type=Subscription, persistentMode=" + persistentMode + ", destinationType=" + destinationType + ", destinationName=" + JMXSupport.encodeObjectNamePart(destinationName) + ", clientID=" + JMXSupport.encodeObjectNamePart(clientID) + "");
SubscriptionView view; SubscriptionView view;
if(sub.getConsumerInfo().isDurable()){ if(sub.getConsumerInfo().isDurable()){
view=new DurableSubscriptionView(this,context.getClientId(),sub); view=new DurableSubscriptionView(this,context.getClientId(),sub);