diff --git a/activemq-broker/src/main/java/org/apache/activemq/network/DurableConduitBridge.java b/activemq-broker/src/main/java/org/apache/activemq/network/DurableConduitBridge.java index afcb42dedc..b4d04f6b0b 100644 --- a/activemq-broker/src/main/java/org/apache/activemq/network/DurableConduitBridge.java +++ b/activemq-broker/src/main/java/org/apache/activemq/network/DurableConduitBridge.java @@ -61,23 +61,19 @@ public class DurableConduitBridge extends ConduitBridge { if (dests != null) { for (ActiveMQDestination dest : dests) { if (isPermissableDestination(dest) && !doesConsumerExist(dest)) { - DemandSubscription sub = createDemandSubscription(dest); - sub.setStaticallyIncluded(true); try { //Filtering by non-empty subscriptions, see AMQ-5875 if (dest.isTopic()) { - sub.getLocalInfo().setSubscriptionName(getSubscriberName(dest)); + String candidateSubName = getSubscriberName(dest); for (Subscription subscription : this.getRegionSubscriptions(dest)) { - String clientId = subscription.getContext().getClientId(); String subName = subscription.getConsumerInfo().getSubscriptionName(); - if (clientId != null && clientId.equals(sub.getLocalInfo().getClientId()) - && subName != null && subName.equals(sub.getLocalInfo().getSubscriptionName())) { + if (subName != null && subName.equals(candidateSubName)) { + DemandSubscription sub = createDemandSubscription(dest); + sub.setStaticallyIncluded(true); addSubscription(sub); break; } } - } else { - addSubscription(sub); } } catch (IOException e) { LOG.error("Failed to add static destination {}", dest, e);