activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nmitt...@apache.org
Subject svn commit: r499401 - in /incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq: connector/stomp/StompConnector.cpp core/ActiveMQConsumer.cpp core/ActiveMQSession.cpp
Date Wed, 24 Jan 2007 13:42:55 GMT
Author: nmittler
Date: Wed Jan 24 05:42:55 2007
New Revision: 499401

URL: http://svn.apache.org/viewvc?view=rev&rev=499401
Log:
[AMQCPP-46] - Updates to properly shutdown a consumer when there is a broken socket to the
broker

Modified:
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConnector.cpp
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConnector.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConnector.cpp?view=diff&rev=499401&r1=499400&r2=499401
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConnector.cpp
(original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConnector.cpp
Wed Jan 24 05:42:55 2007
@@ -714,14 +714,32 @@
 
         if( consumer != NULL)
         {
-            sessionManager->removeConsumer( consumer );
+            try{
+                sessionManager->removeConsumer( consumer );
+            } catch( ConnectorException& ex ){
+                
+                // Make sure we delete the resource
+                delete resource;
+                
+                ex.setMark( __FILE__, __LINE__ );
+                throw ex;
+            }
         }
         else if( session != NULL)
         {
-            sessionManager->removeSession( session );
+            try{
+                sessionManager->removeSession( session );
+            } catch( ConnectorException& ex ){
+                
+                // Make sure we delete the resource
+                delete resource;
+                
+                ex.setMark( __FILE__, __LINE__ );
+                throw ex;
+            }
         }
 
-        // No matter what we end it here.
+        // All went well - finish by deleting the resource.
         delete resource;
     }
     AMQ_CATCH_RETHROW( ConnectorException )

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp?view=diff&rev=499401&r1=499400&r2=499401
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp
(original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp
Wed Jan 24 05:42:55 2007
@@ -67,18 +67,54 @@
     try
     {
         if( !closed ) {
+            
+            closed = true;
+            
+            // Identifies any errors encountered during shutdown.
+            ActiveMQException* error = NULL; 
+            
             // Dispose of the Consumer Info, this should stop us from getting
-            // any more messages.
-            session->onDestroySessionResource( this );
+            // any more messages.  This may result in message traffic
+            // going to the connector.  If the socket is broken, this
+            // will result in an exception, in which case we catch it
+            // and continue to shutdown normally.
+            try{
+                session->onDestroySessionResource( this );
+            } catch( cms::CMSException& ex ){                 
+                error = new ActiveMQException( __FILE__, __LINE__, 
+                        ex.what() );
+            }
             
             // Stop the asynchronous message processin thread if it's
             // running.
-            stopThread();
+            try{
+                stopThread();
+            } catch ( ... ){
+                if( error != NULL ){
+                    error = new ActiveMQException( __FILE__, __LINE__, 
+                        "failed to stop the thread" );
+                }
+            }
             
             // Purge all the pending messages
-            purgeMessages();
+            try{
+                purgeMessages();
+            } catch ( ... ){
+                if( error != NULL ){
+                    error = new ActiveMQException( __FILE__, __LINE__, 
+                        "failed to purge messages from the queue" );
+                }
+            }
             
-            closed = true;
+            // If we encountered an error, propagate it.
+            if( error != NULL ){
+                ActiveMQException ex( *error );
+                delete error;
+                
+                ex.setMark( __FILE__, __LINE__ );
+                throw ex;
+            }
+                                  
         }
     }
     AMQ_CATCH_RETHROW( ActiveMQException )

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp?view=diff&rev=499401&r1=499400&r2=499401
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp
(original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp
Wed Jan 24 05:42:55 2007
@@ -82,8 +82,11 @@
 
     try
     {
-        // Destry the Transaction
-        delete transaction;
+        // Destroy the Transaction
+        if( transaction != NULL ){
+            delete transaction;
+            transaction = NULL;
+        }
 
         // Destroy this sessions resources
         connection->getConnectionData()->



Mime
View raw message