You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2014/12/09 16:36:12 UTC
activemq git commit: https://issues.apache.org/jira/browse/AMQ-5473
Repository: activemq
Updated Branches:
refs/heads/trunk 61a3eab8a -> 164e303e2
https://issues.apache.org/jira/browse/AMQ-5473
Apply patch that allows for durable subs to migrate when links are
stolen.
Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/164e303e
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/164e303e
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/164e303e
Branch: refs/heads/trunk
Commit: 164e303e216ebbc4c7728cb34a47e4ed87c07da9
Parents: 61a3eab
Author: Timothy Bish <ta...@gmail.com>
Authored: Tue Dec 9 10:35:58 2014 -0500
Committer: Timothy Bish <ta...@gmail.com>
Committed: Tue Dec 9 10:35:58 2014 -0500
----------------------------------------------------------------------
.../activemq/broker/region/TopicRegion.java | 28 +++++++++++++++-----
1 file changed, 21 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq/blob/164e303e/activemq-broker/src/main/java/org/apache/activemq/broker/region/TopicRegion.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/region/TopicRegion.java b/activemq-broker/src/main/java/org/apache/activemq/broker/region/TopicRegion.java
index 27e1d28..cea5bb7 100755
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/region/TopicRegion.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/TopicRegion.java
@@ -119,8 +119,10 @@ public class TopicRegion extends AbstractRegion {
SubscriptionKey key = new SubscriptionKey(clientId, subscriptionName);
DurableTopicSubscription sub = durableSubscriptions.get(key);
if (sub != null) {
- if (sub.isActive()) {
- throw new JMSException("Durable consumer is in use for client: " + clientId + " and subscriptionName: " + subscriptionName);
+ // throw this exception only if link stealing is off
+ if (!context.isAllowLinkStealing() && sub.isActive()) {
+ throw new JMSException("Durable consumer is in use for client: " + clientId +
+ " and subscriptionName: " + subscriptionName);
}
// Has the selector changed??
if (hasDurableSubChanged(info, sub.getConsumerInfo())) {
@@ -146,14 +148,24 @@ public class TopicRegion extends AbstractRegion {
if (sub.getConsumerInfo().getConsumerId() != null) {
subscriptions.remove(sub.getConsumerInfo().getConsumerId());
}
+ // set the info and context to the new ones.
+ // this is set in the activate() call below, but
+ // that call is a NOP if it is already active.
+ // hence need to set here and deactivate it first
+ if ((sub.context != context) || (sub.info != info)) {
+ sub.info = info;
+ sub.context = context;
+ sub.deactivate(keepDurableSubsActive);
+ }
subscriptions.put(info.getConsumerId(), sub);
}
} else {
super.addConsumer(context, info);
sub = durableSubscriptions.get(key);
if (sub == null) {
- throw new JMSException("Cannot use the same consumerId: " + info.getConsumerId() + " for two different durable subscriptions clientID: " + key.getClientId()
- + " subscriberName: " + key.getSubscriptionName());
+ throw new JMSException("Cannot use the same consumerId: " + info.getConsumerId() +
+ " for two different durable subscriptions clientID: " + key.getClientId() +
+ " subscriberName: " + key.getSubscriptionName());
}
}
sub.activate(usageManager, context, info, broker);
@@ -166,13 +178,15 @@ public class TopicRegion extends AbstractRegion {
@Override
public void removeConsumer(ConnectionContext context, ConsumerInfo info) throws Exception {
if (info.isDurable()) {
-
SubscriptionKey key = new SubscriptionKey(context.getClientId(), info.getSubscriptionName());
DurableTopicSubscription sub = durableSubscriptions.get(key);
if (sub != null) {
- sub.deactivate(keepDurableSubsActive);
+ // deactivate only if given context is same
+ // as what is in the sub. otherwise, during linksteal
+ // sub will get new context, but will be removed here
+ if (sub.getContext() == context)
+ sub.deactivate(keepDurableSubsActive);
}
-
} else {
super.removeConsumer(context, info);
}