activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1035019 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core: ActiveMQConnection.cpp ActiveMQConnection.h
Date Sun, 14 Nov 2010 16:46:15 GMT
Author: tabish
Date: Sun Nov 14 16:46:15 2010
New Revision: 1035019

URL: http://svn.apache.org/viewvc?rev=1035019&view=rev
Log:
Add a method to get the Resource Manager Id for the Connection, used in XA transactions.

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

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=1035019&r1=1035018&r2=1035019&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
Sun Nov 14 16:46:15 2010
@@ -121,6 +121,7 @@ namespace core{
         Pointer<commands::BrokerInfo> brokerInfo;
         Pointer<commands::WireFormatInfo> brokerWireFormatInfo;
         Pointer<CountDownLatch> transportInterruptionProcessingComplete;
+        Pointer<CountDownLatch> brokerInfoReceived;
 
         Pointer<Exception> firstFailureError;
 
@@ -144,6 +145,7 @@ namespace core{
             this->defaultRedeliveryPolicy.reset( new DefaultRedeliveryPolicy() );
             this->clientIdGenerator.reset(new util::IdGenerator );
             this->connectionInfo.reset( new ConnectionInfo() );
+            this->brokerInfoReceived.reset( new CountDownLatch(1) );
 
             // Generate a connectionId
             decaf::lang::Pointer<ConnectionId> connectionId( new ConnectionId() );
@@ -151,6 +153,9 @@ namespace core{
             this->connectionInfo->setConnectionId( connectionId );
         }
 
+        void waitForBrokerInfo() {
+            this->brokerInfoReceived->await();
+        }
     };
 
     // Static init.
@@ -663,6 +668,7 @@ void ActiveMQConnection::onCommand( cons
         } else if( command->isBrokerInfo() ) {
             this->config->brokerInfo =
                 command.dynamicCast<BrokerInfo>();
+            this->config->brokerInfoReceived->countDown();
         } else if( command->isShutdownInfo() ) {
 
             try {
@@ -714,6 +720,8 @@ void ActiveMQConnection::onException( co
             this->config->firstFailureError.reset( ex.clone() );
         }
 
+        this->config->brokerInfoReceived->countDown();
+
         // TODO - Until this fires in another thread we can't dipose of
         //        the transport here since it could result in this method
         //        being called again recursively.
@@ -1168,3 +1176,17 @@ void ActiveMQConnection::setMessagePrior
 decaf::lang::Exception* ActiveMQConnection::getFirstFailureError() const {
     return this->config->firstFailureError.get();
 }
+
+////////////////////////////////////////////////////////////////////////////////
+std::string ActiveMQConnection::getResourceManagerId() const {
+    try {
+        this->config->waitForBrokerInfo();
+
+        if( this->config->brokerInfo == NULL ) {
+            throw CMSException("Connection failed before Broker info was received.");
+        }
+
+        return this->config->brokerInfo->getBrokerId()->getValue();
+    }
+    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
+}

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.h?rev=1035019&r1=1035018&r2=1035019&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.h Sun
Nov 14 16:46:15 2010
@@ -615,6 +615,14 @@ namespace core{
         transport::Transport& getTransport() const;
 
         /**
+         * Returns the Id of the Resource Manager that this client will use should
+         * it be entered into an XA Transaction.
+         *
+         * @returns a string containing the resource manager Id for XA Transactions.
+         */
+        std::string getResourceManagerId() const;
+
+        /**
          * Clean up this connection object, reseting it back to a state that mirrors
          * what a newly created ActiveMQConnection object has.
          */



Mime
View raw message