From commits-return-11527-apmail-activemq-commits-archive=activemq.apache.org@activemq.apache.org Mon Aug 03 13:54:55 2009 Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 69370 invoked from network); 3 Aug 2009 13:54:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 3 Aug 2009 13:54:55 -0000 Received: (qmail 65677 invoked by uid 500); 3 Aug 2009 13:55:00 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 65626 invoked by uid 500); 3 Aug 2009 13:55:00 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 65617 invoked by uid 99); 3 Aug 2009 13:55:00 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Aug 2009 13:55:00 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Aug 2009 13:54:56 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 4E9EF238887A; Mon, 3 Aug 2009 13:54:35 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r800382 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core: ActiveMQConsumer.cpp ActiveMQProducer.cpp ActiveMQSession.cpp Date: Mon, 03 Aug 2009 13:54:35 -0000 To: commits@activemq.apache.org From: tabish@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090803135435.4E9EF238887A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tabish Date: Mon Aug 3 13:54:34 2009 New Revision: 800382 URL: http://svn.apache.org/viewvc?rev=800382&view=rev Log: Fix for: https://issues.apache.org/activemq/browse/AMQCPP-257 Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQProducer.cpp activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp?rev=800382&r1=800381&r2=800382&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp (original) +++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConsumer.cpp Mon Aug 3 13:54:34 2009 @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -232,10 +233,17 @@ // Stop and Wakeup all sync consumers. unconsumedMessages.close(); - // Remove this Consumer from the Connections set of Dispatchers and then - // remove it from the Broker. + // Remove this Consumer from the Connections set of Dispatchers this->session->disposeOf( this->consumerInfo->getConsumerId(), lastDeliveredSequenceId ); + // Remove at the Broker Side, consumer has been removed from the local + // Session and Connection objects so if the remote call to remove throws + // it is okay to propagate to the client. + Pointer info( new RemoveInfo ); + info->setObjectId( this->consumerInfo->getConsumerId() ); + info->setLastDeliveredSequenceId( lastDeliveredSequenceId ); + this->session->oneway( info ); + // If we encountered an error, propagate it. if( haveException ){ error.setMark( __FILE__, __LINE__ ); Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQProducer.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQProducer.cpp?rev=800382&r1=800381&r2=800382&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQProducer.cpp (original) +++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQProducer.cpp Mon Aug 3 13:54:34 2009 @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -26,6 +27,7 @@ using namespace std; using namespace activemq; using namespace activemq::core; +using namespace activemq::commands; using namespace activemq::exceptions; using namespace decaf::util; using namespace decaf::lang; @@ -74,6 +76,13 @@ this->session->disposeOf( this->producerInfo->getProducerId() ); this->closed = true; + + // Remove at the Broker Side, if this fails the producer has already + // been removed from the session and connection objects so its safe + // for an exception to be thrown. + Pointer info( new RemoveInfo ); + info->setObjectId( this->producerInfo->getProducerId() ); + this->session->oneway( info ); } } AMQ_CATCH_ALL_THROW_CMSEXCEPTION() Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp?rev=800382&r1=800381&r2=800382&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp (original) +++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp Mon Aug 3 13:54:34 2009 @@ -154,15 +154,15 @@ } } + // Remove this sessions from the connection + this->connection->removeSession( this ); + // Remove this session from the Broker. Pointer info( new RemoveInfo() ); info->setObjectId( this->sessionInfo->getSessionId() ); info->setLastDeliveredSequenceId( this->lastDeliveredSequenceId ); this->connection->oneway( info ); - // Remove this sessions from the connector - this->connection->removeSession( this ); - // Now indicate that this session is closed. closed = true; } @@ -1047,16 +1047,9 @@ // Remove this Id both from the Sessions Map of Consumers and from // the Connection. this->connection->removeDispatcher( id ); - - // Remove at the Broker Side. - Pointer info( new RemoveInfo ); - info->setObjectId( id ); - info->setLastDeliveredSequenceId( lastDeliveredSequenceId ); - this->connection->oneway( info ); + this->consumers.remove( id ); this->lastDeliveredSequenceId = Math::max( this->lastDeliveredSequenceId, lastDeliveredSequenceId ); - - this->consumers.remove( id ); } } } @@ -1078,12 +1071,6 @@ if( this->producers.containsKey( id ) ) { this->connection->removeProducer( id ); - - // Remove at the Broker Side. - Pointer info( new RemoveInfo ); - info->setObjectId( id ); - this->connection->oneway( info ); - this->producers.remove( id ); } }