mirror of https://github.com/apache/activemq.git
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:
parent
3c9a89ac1a
commit
a20de10f4a
|
@ -171,42 +171,48 @@ 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());
|
||||||
SubscriptionKey key = new SubscriptionKey(context.getClientId(), sub.getConsumerInfo().getSubcriptionName());
|
String clientId="clientId="+JMXSupport.encodeObjectNamePart(context.getClientId());
|
||||||
|
String persistentMode="persistentMode=";
|
||||||
if (sub.getConsumerInfo().isDurable()) {
|
String consumerId="";
|
||||||
persistentMode = "Durable, subscriptionID=" + JMXSupport.encodeObjectNamePart(sub.getConsumerInfo().getSubcriptionName());
|
SubscriptionKey key=new SubscriptionKey(context.getClientId(),sub.getConsumerInfo().getSubcriptionName());
|
||||||
} else {
|
if(sub.getConsumerInfo().isDurable()){
|
||||||
persistentMode = "Non-Durable";
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
objectNameStr+=persistentMode+",";
|
||||||
destinationType = sub.getConsumerInfo().getDestination().getDestinationTypeAsString();
|
objectNameStr+=destinationType+",";
|
||||||
destinationName = sub.getConsumerInfo().getDestination().getPhysicalName();
|
objectNameStr+=destinationName+",";
|
||||||
clientID = context.getClientId();
|
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);
|
||||||
} else {
|
}else{
|
||||||
if (sub instanceof TopicSubscription) {
|
if(sub instanceof TopicSubscription){
|
||||||
view = new TopicSubscriptionView(context.getClientId(), (TopicSubscription) sub);
|
view=new TopicSubscriptionView(context.getClientId(),(TopicSubscription)sub);
|
||||||
} else {
|
}else{
|
||||||
view = new SubscriptionView(context.getClientId(), sub);
|
view=new SubscriptionView(context.getClientId(),sub);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
registerSubscription(objectName, sub.getConsumerInfo(), key, view);
|
registerSubscription(objectName,sub.getConsumerInfo(),key,view);
|
||||||
subscriptionMap.put(sub, objectName);
|
subscriptionMap.put(sub,objectName);
|
||||||
return objectName;
|
return objectName;
|
||||||
} catch (Exception e) {
|
}catch(Exception e){
|
||||||
log.error("Failed to register subscription " + sub, e);
|
log.error("Failed to register subscription "+sub,e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue