mirror of https://github.com/apache/activemq.git
make absolutely sure that a session is always removed from the connection even if there is a failure while closing
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@451323 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3c441d03ae
commit
72491912ad
|
@ -165,8 +165,6 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon
|
|||
* Construct an <code>ActiveMQConnection</code>
|
||||
* @param transport
|
||||
* @param factoryStats
|
||||
* @param userName
|
||||
* @param password
|
||||
* @throws Exception
|
||||
*/
|
||||
protected ActiveMQConnection(final Transport transport, IdGenerator clientIdGenerator, JMSStatsImpl factoryStats)
|
||||
|
|
|
@ -535,32 +535,36 @@ public class ActiveMQSession implements Session, QueueSession, TopicSession, Sta
|
|||
synchronized public void dispose() throws JMSException {
|
||||
if (!closed) {
|
||||
|
||||
executor.stop();
|
||||
|
||||
for (Iterator iter = consumers.iterator(); iter.hasNext();) {
|
||||
ActiveMQMessageConsumer consumer = (ActiveMQMessageConsumer) iter.next();
|
||||
consumer.dispose();
|
||||
}
|
||||
consumers.clear();
|
||||
|
||||
for (Iterator iter = producers.iterator(); iter.hasNext();) {
|
||||
ActiveMQMessageProducer producer = (ActiveMQMessageProducer) iter.next();
|
||||
producer.dispose();
|
||||
}
|
||||
producers.clear();
|
||||
|
||||
try {
|
||||
if (getTransactionContext().isInLocalTransaction()) {
|
||||
rollback();
|
||||
executor.stop();
|
||||
|
||||
for (Iterator iter = consumers.iterator(); iter.hasNext();) {
|
||||
ActiveMQMessageConsumer consumer = (ActiveMQMessageConsumer) iter.next();
|
||||
consumer.dispose();
|
||||
}
|
||||
} catch (JMSException e) {
|
||||
consumers.clear();
|
||||
|
||||
for (Iterator iter = producers.iterator(); iter.hasNext();) {
|
||||
ActiveMQMessageProducer producer = (ActiveMQMessageProducer) iter.next();
|
||||
producer.dispose();
|
||||
}
|
||||
producers.clear();
|
||||
|
||||
try {
|
||||
if (getTransactionContext().isInLocalTransaction()) {
|
||||
rollback();
|
||||
}
|
||||
}
|
||||
catch (JMSException e) {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
finally {
|
||||
connection.removeSession(this);
|
||||
this.transactionContext = null;
|
||||
closed = true;
|
||||
}
|
||||
|
||||
|
||||
connection.removeSession(this);
|
||||
this.transactionContext=null;
|
||||
closed = true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue