activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1148943 - /activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp
Date Wed, 20 Jul 2011 21:10:44 GMT
Author: tabish
Date: Wed Jul 20 21:10:43 2011
New Revision: 1148943

URL: http://svn.apache.org/viewvc?rev=1148943&view=rev
Log:
Adds some additional error handling in the connection close case to allow the full close process
to be tried before an exception is thrown, this should allow the socket to get closed even
if there's an issue sending the remove or shutdown commands.

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp?rev=1148943&r1=1148942&r2=1148943&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp
Wed Jul 20 21:10:43 2011
@@ -540,40 +540,56 @@ void ActiveMQConnection::disconnect( lon
         // Clear the listener, we don't care about async errors at this point.
         this->config->transport->setTransportListener( NULL );
 
-        if( this->config->isConnectionInfoSentToBroker ) {
-
-            // Remove our ConnectionId from the Broker
-            Pointer<RemoveInfo> command( this->config->connectionInfo->createRemoveCommand()
);
-            command->setLastDeliveredSequenceId( lastDeliveredSequenceId );
-            this->syncRequest( command, this->config->closeTimeout );
-
-            // Send the disconnect command to the broker.
-            Pointer<ShutdownInfo> shutdown( new ShutdownInfo() );
-            oneway( shutdown );
-        }
-
         // Allow the Support class to shutdown its resources, including the Transport.
         bool hasException = false;
         exceptions::ActiveMQException e;
 
-        if( this->config->transport != NULL ){
+        if (this->config->isConnectionInfoSentToBroker) {
 
-            try{
+            try {
+                // Remove our ConnectionId from the Broker
+                Pointer<RemoveInfo> command(this->config->connectionInfo->createRemoveCommand());
+                command->setLastDeliveredSequenceId(lastDeliveredSequenceId);
+                this->syncRequest(command, this->config->closeTimeout);
+            } catch(exceptions::ActiveMQException& ex) {
+                if (!hasException) {
+                    hasException = true;
+                    ex.setMark(__FILE__, __LINE__);
+                    e = ex;
+                }
+            }
+
+            try {
+                // Send the disconnect command to the broker.
+                Pointer<ShutdownInfo> shutdown(new ShutdownInfo());
+                oneway(shutdown);
+            } catch(exceptions::ActiveMQException& ex) {
+                if (!hasException) {
+                    hasException = true;
+                    ex.setMark(__FILE__, __LINE__);
+                    e = ex;
+                }
+            }
+        }
+
+        if (this->config->transport != NULL) {
+
+            try {
                 this->config->transport->close();
-            }catch( exceptions::ActiveMQException& ex ){
-                if( !hasException ){
+            } catch(exceptions::ActiveMQException& ex) {
+                if (!hasException) {
                     hasException = true;
-                    ex.setMark(__FILE__, __LINE__ );
+                    ex.setMark(__FILE__, __LINE__);
                     e = ex;
                 }
             }
 
-            try{
-                this->config->transport.reset( NULL );
-            }catch( exceptions::ActiveMQException& ex ){
-                if( !hasException ){
+            try {
+                this->config->transport.reset(NULL);
+            } catch(exceptions::ActiveMQException& ex) {
+                if (!hasException) {
                     hasException = true;
-                    ex.setMark(__FILE__, __LINE__ );
+                    ex.setMark(__FILE__, __LINE__);
                     e = ex;
                 }
             }
@@ -581,7 +597,7 @@ void ActiveMQConnection::disconnect( lon
 
         // If we encountered an exception - throw the first one we encountered.
         // This will preserve the stack trace for logging purposes.
-        if( hasException ){
+        if (hasException) {
             throw e;
         }
     }



Mime
View raw message