From e82d0fb47067a34aec9d0ddb5fe6513fdf1ee76b Mon Sep 17 00:00:00 2001 From: James Strachan Date: Thu, 16 Feb 2006 11:21:38 +0000 Subject: [PATCH] avoid throwing exceptions to clients if a consumer has already been closed (maybe asynchronously) git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@378226 13f79535-47bb-0310-9956-ffa450edef68 --- .../activemq/broker/AbstractConnection.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/AbstractConnection.java b/activemq-core/src/main/java/org/apache/activemq/broker/AbstractConnection.java index 6da09bf1f2..657ea96d76 100755 --- a/activemq-core/src/main/java/org/apache/activemq/broker/AbstractConnection.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/AbstractConnection.java @@ -72,6 +72,7 @@ import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap; */ public abstract class AbstractConnection implements Service, Connection, Task, CommandVisitor { + private static final Log log = LogFactory.getLog(AbstractConnection.class.getName()); private static final Log transportLog = LogFactory.getLog(AbstractConnection.class.getName() + ".Transport"); private static final Log serviceLog = LogFactory.getLog(AbstractConnection.class.getName() + ".Service"); @@ -441,7 +442,6 @@ public abstract class AbstractConnection implements Service, Connection, Task, C } public Response processRemoveSession(SessionId id) throws Throwable { - ConnectionId connectionId = id.getParentId(); ConnectionState cs = lookupConnectionState(connectionId); @@ -451,10 +451,22 @@ public abstract class AbstractConnection implements Service, Connection, Task, C // Cascade the connection stop to the consumers and producers. for (Iterator iter = session.getConsumerIds().iterator(); iter.hasNext();) { - processRemoveConsumer((ConsumerId) iter.next()); + ConsumerId consumerId = (ConsumerId) iter.next(); + try { + processRemoveConsumer(consumerId); + } + catch (Throwable e) { + log.warn("Failed to remove consumer: " + consumerId + ". Reason: " + e, e); + } } for (Iterator iter = session.getProducerIds().iterator(); iter.hasNext();) { - processRemoveProducer((ProducerId) iter.next()); + ProducerId producerId = (ProducerId) iter.next(); + try { + processRemoveProducer(producerId); + } + catch (Throwable e) { + log.warn("Failed to remove producer: " + producerId + ". Reason: " + e, e); + } } cs.removeSession(id); broker.removeSession(cs.getContext(), session.getInfo());