Don't check connection splits for temporary destinations

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@637046 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Davies 2008-03-14 10:44:52 +00:00
parent bbd2e47dbd
commit ceb7e1a86c
1 changed files with 25 additions and 21 deletions

View File

@ -23,6 +23,7 @@ import org.apache.activemq.broker.Broker;
import org.apache.activemq.broker.BrokerFilter; import org.apache.activemq.broker.BrokerFilter;
import org.apache.activemq.broker.ConnectionContext; import org.apache.activemq.broker.ConnectionContext;
import org.apache.activemq.broker.region.Subscription; import org.apache.activemq.broker.region.Subscription;
import org.apache.activemq.command.ActiveMQDestination;
import org.apache.activemq.command.ConsumerId; import org.apache.activemq.command.ConsumerId;
import org.apache.activemq.command.ConsumerInfo; import org.apache.activemq.command.ConsumerInfo;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@ -44,31 +45,34 @@ public class ConnectionSplitBroker extends BrokerFilter{
public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception{ public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception{
ActiveMQDestination dest = info.getDestination();
synchronized (networkConsumerList) { boolean validDestination = dest != null && !dest.isTemporary();
if (info.isNetworkSubscription()) { if (validDestination) {
networkConsumerList.add(info); synchronized (networkConsumerList) {
} else { if (info.isNetworkSubscription()) {
if(!networkConsumerList.isEmpty()) { networkConsumerList.add(info);
List<ConsumerInfo> gcList = new ArrayList<ConsumerInfo>(); } else {
for (ConsumerInfo nc : networkConsumerList) { if(!networkConsumerList.isEmpty()) {
if (!nc.isNetworkConsumersEmpty()) { List<ConsumerInfo> gcList = new ArrayList<ConsumerInfo>();
for (ConsumerId id : nc.getNetworkConsumerIds()) { for (ConsumerInfo nc : networkConsumerList) {
if (id.equals(info.getConsumerId())) { if (!nc.isNetworkConsumersEmpty()) {
nc.removeNetworkConsumerId(id); for (ConsumerId id : nc.getNetworkConsumerIds()) {
if (nc.isNetworkConsumersEmpty()) { if (id.equals(info.getConsumerId())) {
gcList.add(nc); nc.removeNetworkConsumerId(id);
if (nc.isNetworkConsumersEmpty()) {
gcList.add(nc);
}
} }
} }
} else {
gcList.add(nc);
} }
} else {
gcList.add(nc);
} }
} for (ConsumerInfo nc : gcList) {
for (ConsumerInfo nc : gcList) { networkConsumerList.remove(nc);
networkConsumerList.remove(nc); super.removeConsumer(context, nc);
super.removeConsumer(context, nc); LOG.warn("Removed stale network consumer " + nc);
LOG.warn("Removed stale network consumer " + nc); }
} }
} }
} }