mirror of https://github.com/apache/activemq.git
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@669512 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e38da226ef
commit
1555260c6c
|
@ -183,6 +183,7 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon
|
|||
private long timeCreated;
|
||||
private ConnectionAudit connectionAudit = new ConnectionAudit();
|
||||
private DestinationSource destinationSource;
|
||||
private final Object ensureConnectionInfoSentMutex = new Object();
|
||||
|
||||
/**
|
||||
* Construct an <code>ActiveMQConnection</code>
|
||||
|
@ -524,12 +525,14 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon
|
|||
public void stop() throws JMSException {
|
||||
checkClosedOrFailed();
|
||||
if (started.compareAndSet(true, false)) {
|
||||
synchronized(sessions) {
|
||||
for (Iterator<ActiveMQSession> i = sessions.iterator(); i.hasNext();) {
|
||||
ActiveMQSession s = i.next();
|
||||
s.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the connection.
|
||||
|
@ -577,7 +580,9 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon
|
|||
public void close() throws JMSException {
|
||||
try {
|
||||
// If we were running, lets stop first.
|
||||
if (!closed.get() && !transportFailed.get()) {
|
||||
stop();
|
||||
}
|
||||
|
||||
synchronized (this) {
|
||||
if (!closed.get()) {
|
||||
|
@ -626,16 +631,18 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon
|
|||
// then we may need to call
|
||||
// factory.onConnectionClose(this);
|
||||
sessionTaskRunner.shutdown();
|
||||
|
||||
if (asyncConnectionThread != null){
|
||||
asyncConnectionThread.shutdown();
|
||||
}
|
||||
|
||||
closed.set(true);
|
||||
closing.set(false);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
if (asyncConnectionThread != null){
|
||||
asyncConnectionThread.shutdown();
|
||||
}
|
||||
}catch(Throwable e) {
|
||||
LOG.error("Error shutting down thread pool " + e,e);
|
||||
}
|
||||
factoryStats.removeConnection(this);
|
||||
}
|
||||
}
|
||||
|
@ -1226,6 +1233,9 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon
|
|||
if (er.getException() instanceof JMSException) {
|
||||
throw (JMSException)er.getException();
|
||||
} else {
|
||||
if (isClosed()||closing.get()) {
|
||||
LOG.debug("Received an exception but connection is closing");
|
||||
}
|
||||
JMSException jmsEx = null;
|
||||
try {
|
||||
jmsEx = JMSExceptionSupport.create(er.getException());
|
||||
|
@ -1313,7 +1323,8 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon
|
|||
*
|
||||
* @throws JMSException
|
||||
*/
|
||||
protected synchronized void ensureConnectionInfoSent() throws JMSException {
|
||||
protected void ensureConnectionInfoSent() throws JMSException {
|
||||
synchronized(this.ensureConnectionInfoSentMutex) {
|
||||
// Can we skip sending the ConnectionInfo packet??
|
||||
if (isConnectionInfoSentToBroker || closed.get()) {
|
||||
return;
|
||||
|
@ -1334,6 +1345,7 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon
|
|||
advisoryConsumer = new AdvisoryConsumer(this, consumerId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized boolean isWatchTopicAdvisories() {
|
||||
return watchTopicAdvisories;
|
||||
|
|
Loading…
Reference in New Issue