https://issues.apache.org/jira/browse/AMQ-3353 - fix regression in NoDuplicateOnTopicNetworkTest, suppression only relevant to active durable subs

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1153588 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary Tully 2011-08-03 17:26:15 +00:00
parent 01ae0eaf92
commit a6b85cc9f3
3 changed files with 10 additions and 6 deletions

View File

@ -270,7 +270,7 @@ public class DurableTopicSubscription extends PrefetchSubscription implements Us
public synchronized String toString() {
return "DurableTopicSubscription-" + getSubscriptionKey() + ", id=" + info.getConsumerId() + ", destinations=" + destinations.size() + ", total=" + enqueueCounter + ", pending="
return "DurableTopicSubscription-" + getSubscriptionKey() + ", id=" + info.getConsumerId() + ", active=" + isActive() + ", destinations=" + destinations.size() + ", total=" + enqueueCounter + ", pending="
+ getPendingQueueSize() + ", dispatched=" + dispatchCounter + ", inflight=" + dispatched.size() + ", prefetchExtension=" + this.prefetchExtension;
}

View File

@ -1048,7 +1048,11 @@ public abstract class DemandForwardingBridgeSupport implements NetworkBridge, Br
List<ConsumerId> networkConsumers = sub.getConsumerInfo().getNetworkConsumerIds();
if (!networkConsumers.isEmpty()) {
if (matchFound(candidateConsumers, networkConsumers)) {
suppress = isActiveDurableSub(sub) && hasLowerPriority(sub, candidate.getLocalInfo());
if (isInActiveDurableSub(sub)) {
suppress = false;
} else {
suppress = hasLowerPriority(sub, candidate.getLocalInfo());
}
break;
}
}
@ -1056,8 +1060,8 @@ public abstract class DemandForwardingBridgeSupport implements NetworkBridge, Br
return suppress;
}
private boolean isActiveDurableSub(Subscription sub) {
return (sub.getConsumerInfo().isDurable() && sub instanceof DurableTopicSubscription && ((DurableTopicSubscription)sub).isActive());
private boolean isInActiveDurableSub(Subscription sub) {
return (sub.getConsumerInfo().isDurable() && sub instanceof DurableTopicSubscription && !((DurableTopicSubscription)sub).isActive());
}
private boolean hasLowerPriority(Subscription existingSub, ConsumerInfo candidateInfo) {
@ -1067,7 +1071,7 @@ public abstract class DemandForwardingBridgeSupport implements NetworkBridge, Br
if (LOG.isDebugEnabled()) {
LOG.debug(configuration.getBrokerName() + " Ignoring duplicate subscription from " + remoteBrokerName
+ ", sub: " + candidateInfo + " is duplicated by network subscription with equal or higher network priority: "
+ existingSub.getConsumerInfo() + ", networkComsumerIds: " + existingSub.getConsumerInfo().getNetworkConsumerIds());
+ existingSub + ", networkConsumerIds: " + existingSub.getConsumerInfo().getNetworkConsumerIds());
}
suppress = true;
} else {

View File

@ -117,7 +117,7 @@ public class NoDuplicateOnTopicNetworkTest extends CombinationTestSupport {
private BrokerService createAndStartBroker(String name, String addr)
throws Exception {
BrokerService broker = new BrokerService();
//broker.setDeleteAllMessagesOnStartup(true);
broker.setDeleteAllMessagesOnStartup(true);
broker.setBrokerName(name);
broker.addConnector(addr).setDiscoveryUri(new URI(MULTICAST_DEFAULT));
broker.setUseJmx(false);