activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject [1/2] activemq git commit: release the connection even if broker communication fails
Date Thu, 19 Nov 2015 18:18:05 GMT
Repository: activemq
Updated Branches:
  refs/heads/master cf5735320 -> d730e35f9


release the connection even if broker communication fails


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/934f3cea
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/934f3cea
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/934f3cea

Branch: refs/heads/master
Commit: 934f3cea7effdff3b43ddabc9d0f03535fa44e5f
Parents: 64aac4c
Author: Romain Manni-Bucau <rmannibu@gmail.com>
Authored: Thu Nov 19 07:48:56 2015 -0800
Committer: Romain Manni-Bucau <rmannibu@gmail.com>
Committed: Thu Nov 19 07:48:56 2015 -0800

----------------------------------------------------------------------
 .../org/apache/activemq/ActiveMQConnection.java | 52 ++++++++++----------
 1 file changed, 27 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/934f3cea/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnection.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnection.java b/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnection.java
index 50a64d8..aecece1 100755
--- a/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnection.java
+++ b/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnection.java
@@ -678,34 +678,36 @@ public class ActiveMQConnection implements Connection, TopicConnection,
QueueCon
 
                     this.activeTempDestinations.clear();
 
-                    if (isConnectionInfoSentToBroker) {
-                        // If we announced ourselves to the broker.. Try to let the broker
-                        // know that the connection is being shutdown.
-                        RemoveInfo removeCommand = info.createRemoveCommand();
-                        removeCommand.setLastDeliveredSequenceId(lastDeliveredSequenceId);
-                        try {
-                            doSyncSendPacket(removeCommand, closeTimeout);
-                        } catch (JMSException e) {
-                            if (e.getCause() instanceof RequestTimedOutIOException) {
-                                // expected
-                            } else {
-                                throw e;
+                    try {
+                        if (isConnectionInfoSentToBroker) {
+                            // If we announced ourselves to the broker.. Try to let the broker
+                            // know that the connection is being shutdown.
+                            RemoveInfo removeCommand = info.createRemoveCommand();
+                            removeCommand.setLastDeliveredSequenceId(lastDeliveredSequenceId);
+                            try {
+                                doSyncSendPacket(removeCommand, closeTimeout);
+                            } catch (JMSException e) {
+                                if (e.getCause() instanceof RequestTimedOutIOException) {
+                                    // expected
+                                } else {
+                                    throw e;
+                                }
                             }
+                            doAsyncSendPacket(new ShutdownInfo());
                         }
-                        doAsyncSendPacket(new ShutdownInfo());
-                    }
-
-                    started.set(false);
-
-                    // TODO if we move the TaskRunnerFactory to the connection
-                    // factory
-                    // then we may need to call
-                    // factory.onConnectionClose(this);
-                    if (sessionTaskRunner != null) {
-                        sessionTaskRunner.shutdown();
+                    } finally { // release anyway even if previous communication fails
+                        started.set(false);
+
+                        // TODO if we move the TaskRunnerFactory to the connection
+                        // factory
+                        // then we may need to call
+                        // factory.onConnectionClose(this);
+                        if (sessionTaskRunner != null) {
+                            sessionTaskRunner.shutdown();
+                        }
+                        closed.set(true);
+                        closing.set(false);
                     }
-                    closed.set(true);
-                    closing.set(false);
                 }
             }
         } finally {


Mime
View raw message