activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1419565 - /activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/
Date Mon, 10 Dec 2012 16:31:01 GMT
Author: tabish
Date: Mon Dec 10 16:30:59 2012
New Revision: 1419565

URL: http://svn.apache.org/viewvc?rev=1419565&view=rev
Log:
Clean up example code in preparation for next release. 

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/CMSTestMultipleSendersReceivers.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/CmsMessageCreator.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/CmsMessageCreator.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/CmsMessageHandlerDefinitions.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/ConnectionFactoryMgr.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/ConnectionFactoryMgr.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/MessagingTask.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/MessagingTask.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/Sender.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/Sender.h

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/CMSTestMultipleSendersReceivers.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/CMSTestMultipleSendersReceivers.cpp?rev=1419565&r1=1419564&r2=1419565&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/CMSTestMultipleSendersReceivers.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/CMSTestMultipleSendersReceivers.cpp
Mon Dec 10 16:30:59 2012
@@ -18,6 +18,7 @@
 #include <iostream>
 #include <string>
 #include <cstdio>
+#include <vector>
 
 #include <decaf/lang/Thread.h>
 #include <decaf/lang/Integer.h>
@@ -58,24 +59,26 @@ int main(int argc, char** argv) {
     int reservedThreads = 3;
     Receiver::Initialize(reservedThreads, maxThreads);
 
-    TestSenderAndReceiver **sar = new TestSenderAndReceiver *[cnt];
+    std::vector<TestSenderAndReceiver*> sar;
+    sar.resize(cnt);
 
     for (int i = 0; i < cnt; i++) {
         string topic("topic");
         stringstream str;
         str << i;
         topic += str.str();
-        sar[i] = new TestSenderAndReceiver(url, topic.c_str(), true, false, 50, 1000);
+        sar[i] = new TestSenderAndReceiver(url, topic, true, false, 50, 1000);
         sar[i]->init();
     }
 
     Thread::sleep(done * 1000);
 
     for (int i = 0; i < cnt; i++) {
-        sar[i]->close();
+        try {
+            sar[i]->close();
+        } catch(...) {}
         delete sar[i];
     }
-    delete sar;
 
     printf("\nTest Completed!\n");
 }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/CmsMessageCreator.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/CmsMessageCreator.cpp?rev=1419565&r1=1419564&r2=1419565&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/CmsMessageCreator.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/CmsMessageCreator.cpp
Mon Dec 10 16:30:59 2012
@@ -17,17 +17,14 @@
 
 #include "CmsMessageCreator.h"
 
+#include <memory>
+
 using namespace std;
 using namespace cms;
-using namespace decaf;
-using namespace decaf::lang;
-using namespace decaf::util;
-using namespace decaf::util::concurrent;
-using namespace activemq::core;
 using namespace cmstemplate;
 
 ////////////////////////////////////////////////////////////////////////////////
-CmsMessageCreator::CmsMessageCreator(const std::string& txt) : m_txt(txt) {
+CmsMessageCreator::CmsMessageCreator(const std::string& text) : text(text) {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -36,9 +33,11 @@ CmsMessageCreator::~CmsMessageCreator() 
 
 ////////////////////////////////////////////////////////////////////////////////
 cms::Message* CmsMessageCreator::createMessage(cms::Session* session) {
-    cms::Message* message = NULL;
+    std::auto_ptr<cms::Message> message;
+
     if (session) {
-        message = session->createTextMessage(m_txt);
+        message.reset(session->createTextMessage(text));
     }
-    return message;
+
+    return message.release();
 }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/CmsMessageCreator.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/CmsMessageCreator.h?rev=1419565&r1=1419564&r2=1419565&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/CmsMessageCreator.h
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/CmsMessageCreator.h
Mon Dec 10 16:30:59 2012
@@ -18,15 +18,9 @@
 #ifndef _CMSTEMPLATE_CMSMESSAGECREATOR_H_
 #define _CMSTEMPLATE_CMSMESSAGECREATOR_H_
 
-#include <activemq/core/ActiveMQConnectionFactory.h>
-#include <activemq/core/ActiveMQConnection.h>
-#include <activemq/library/ActiveMQCPP.h>
 #include <cms/Connection.h>
 #include <cms/Session.h>
-#include <cms/ExceptionListener.h>
-#include <cms/MessageListener.h>
 
-#include <activemq/cmsutil/CmsTemplate.h>
 #include <activemq/cmsutil/MessageCreator.h>
 
 namespace cmstemplate {
@@ -34,11 +28,11 @@ namespace cmstemplate {
     class CmsMessageCreator : public activemq::cmsutil::MessageCreator {
     private:
 
-        std::string m_txt;
+        std::string text;
 
     public:
 
-        CmsMessageCreator(const std::string& txt);
+        CmsMessageCreator(const std::string& text);
 
         virtual ~CmsMessageCreator();
         virtual cms::Message* createMessage(cms::Session* session);

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/CmsMessageHandlerDefinitions.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/CmsMessageHandlerDefinitions.h?rev=1419565&r1=1419564&r2=1419565&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/CmsMessageHandlerDefinitions.h
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/CmsMessageHandlerDefinitions.h
Mon Dec 10 16:30:59 2012
@@ -81,8 +81,5 @@ namespace cmstemplate {
     #define ErrorCodeToString(i) (((i >= CMS_SUCCESS) && (i <= CMS_LAST)) ?
ErrorDescription[i] : ErrorDescription[CMS_LAST])
     #define IsError(i) (i != CMS_SUCCESS)
 }
-//typedef void (CALLBACK* MessageListener)( IDispatch* message, VARIANT* headerNames, VARIANT*
headerValues);
-//
-//typedef void (CALLBACK* BrokerStatusListener)( BSTR brokerIP, BSTR brokerPort, VARIANT_BOOL
isBrokerGood, LONGLONG timeStamp);
 
 #endif /** _CMSTEMPLATE_CMSMESSAGEHANDLERDEFINITIONS_H_ */

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/ConnectionFactoryMgr.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/ConnectionFactoryMgr.cpp?rev=1419565&r1=1419564&r2=1419565&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/ConnectionFactoryMgr.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/ConnectionFactoryMgr.cpp
Mon Dec 10 16:30:59 2012
@@ -28,7 +28,7 @@ using namespace activemq::core;
 using namespace cmstemplate;
 
 ////////////////////////////////////////////////////////////////////////////////
-StlMap<std::string, ConnectionFactory*> * ConnectionFactoryMgr::m_connectionFactories;
+StlMap<std::string, ConnectionFactory*> * ConnectionFactoryMgr::connectionFactories;
 
 ////////////////////////////////////////////////////////////////////////////////
 ConnectionFactoryMgr::ConnectionFactoryMgr() {
@@ -44,14 +44,14 @@ ConnectionFactoryMgr::~ConnectionFactory
 
 ////////////////////////////////////////////////////////////////////////////////
 void ConnectionFactoryMgr::Initialize() {
-    m_connectionFactories = new StlMap<std::string, ConnectionFactory*>();
+    connectionFactories = new StlMap<std::string, ConnectionFactory*>();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 void ConnectionFactoryMgr::UnInitialize() {
-    m_connectionFactories->lock();
+    connectionFactories->lock();
 
-    Pointer<Iterator<ConnectionFactory*> > iter(m_connectionFactories->values().iterator());
+    Pointer<Iterator<ConnectionFactory*> > iter(connectionFactories->values().iterator());
     while (iter->hasNext()) {
         ConnectionFactory* connectionFactory = iter->next();
         if (connectionFactory != NULL) {
@@ -59,29 +59,29 @@ void ConnectionFactoryMgr::UnInitialize(
             connectionFactory = NULL;
         }
     }
-    m_connectionFactories->clear();
 
-    m_connectionFactories->unlock();
+    connectionFactories->clear();
+    connectionFactories->unlock();
 
-    delete m_connectionFactories;
-    m_connectionFactories = NULL;
+    delete connectionFactories;
+    connectionFactories = NULL;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 ConnectionFactory* ConnectionFactoryMgr::GetConnectionFactory(const std::string& url)
{
     ConnectionFactory* connectionFactory = NULL;
 
-    m_connectionFactories->lock();
+    connectionFactories->lock();
     try {
-        connectionFactory = m_connectionFactories->get(url);
+        connectionFactory = connectionFactories->get(url);
     } catch (NoSuchElementException& ex) {
     }
 
     if (!connectionFactory) {
         connectionFactory = new ActiveMQConnectionFactory(url);
-        m_connectionFactories->put(url, connectionFactory);
+        connectionFactories->put(url, connectionFactory);
     }
-    m_connectionFactories->unlock();
+    connectionFactories->unlock();
 
     return connectionFactory;
 }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/ConnectionFactoryMgr.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/ConnectionFactoryMgr.h?rev=1419565&r1=1419564&r2=1419565&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/ConnectionFactoryMgr.h
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/ConnectionFactoryMgr.h
Mon Dec 10 16:30:59 2012
@@ -26,7 +26,7 @@ namespace cmstemplate {
     class ConnectionFactoryMgr {
     private:
 
-        static decaf::util::StlMap <std::string, cms::ConnectionFactory *> *m_connectionFactories;
+        static decaf::util::StlMap <std::string, cms::ConnectionFactory *> *connectionFactories;
 
         ConnectionFactoryMgr();
 
@@ -35,7 +35,9 @@ namespace cmstemplate {
     public:
 
         static void Initialize();
+
         static void UnInitialize();
+
         static cms::ConnectionFactory* GetConnectionFactory(const std::string& url);
 
     };

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/MessagingTask.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/MessagingTask.cpp?rev=1419565&r1=1419564&r2=1419565&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/MessagingTask.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/MessagingTask.cpp
Mon Dec 10 16:30:59 2012
@@ -21,7 +21,7 @@ using namespace std;
 using namespace cmstemplate;
 
 ////////////////////////////////////////////////////////////////////////////////
-MessagingTask::MessagingTask(Receiver* receiver, const string& message) : m_receiver(receiver),
m_message(message) {
+MessagingTask::MessagingTask(Receiver* receiver, const string& message) : receiver(receiver),
message(message) {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -31,8 +31,8 @@ MessagingTask::~MessagingTask() {
 ////////////////////////////////////////////////////////////////////////////////
 void MessagingTask::run() {
     try {
-        if (m_receiver != NULL) {
-            m_receiver->ExecuteMessagingTask(m_message);
+        if (receiver != NULL) {
+            receiver->ExecuteMessagingTask(message);
         }
     } catch (...) {
     }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/MessagingTask.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/MessagingTask.h?rev=1419565&r1=1419564&r2=1419565&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/MessagingTask.h
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/MessagingTask.h
Mon Dec 10 16:30:59 2012
@@ -26,8 +26,8 @@ namespace cmstemplate {
     class MessagingTask : public decaf::lang::Runnable {
     private:
 
-        Receiver* m_receiver;
-        std::string m_message;
+        Receiver* receiver;
+        std::string message;
 
     private:
 
@@ -36,7 +36,7 @@ namespace cmstemplate {
 
     public:
 
-        MessagingTask(Receiver* m_receiver, const std::string& message);
+        MessagingTask(Receiver* receiver, const std::string& message);
 
         virtual ~MessagingTask();
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/Sender.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/Sender.cpp?rev=1419565&r1=1419564&r2=1419565&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/Sender.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/Sender.cpp Mon
Dec 10 16:30:59 2012
@@ -31,27 +31,27 @@ using namespace cmstemplate;
 
 ////////////////////////////////////////////////////////////////////////////////
 Sender::Sender(const string& url, const string& queueOrTopicName, bool isTopic, bool
isDeliveryPersistent, int timeToLive) :
-    m_cmsTemplateMutex(), m_cmsTemplate(NULL) {
+    cmsTemplateMutex(), cmsTemplate(NULL) {
 
     ConnectionFactory* connectionFactory = ConnectionFactoryMgr::GetConnectionFactory(url);
 
-    m_cmsTemplate = new CmsTemplate(connectionFactory);
-    m_cmsTemplate->setExplicitQosEnabled(true);
-    m_cmsTemplate->setDefaultDestinationName(queueOrTopicName);
-    m_cmsTemplate->setPubSubDomain(isTopic);
-    m_cmsTemplate->setDeliveryPersistent(isDeliveryPersistent);
-    m_cmsTemplate->setTimeToLive(timeToLive);
+    cmsTemplate = new CmsTemplate(connectionFactory);
+    cmsTemplate->setExplicitQosEnabled(true);
+    cmsTemplate->setDefaultDestinationName(queueOrTopicName);
+    cmsTemplate->setPubSubDomain(isTopic);
+    cmsTemplate->setDeliveryPersistent(isDeliveryPersistent);
+    cmsTemplate->setTimeToLive(timeToLive);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 Sender::~Sender() {
     try {
-        m_cmsTemplateMutex.lock();
-        if (m_cmsTemplate) {
-            delete m_cmsTemplate;
-            m_cmsTemplate = NULL;
+        cmsTemplateMutex.lock();
+        if (cmsTemplate) {
+            delete cmsTemplate;
+            cmsTemplate = NULL;
         }
-        m_cmsTemplateMutex.unlock();
+        cmsTemplateMutex.unlock();
     } catch (...) {
     }
 }
@@ -64,12 +64,12 @@ void Sender::SendMessage(string& message
 
     // send message through a CmsTemplate
     try {
-        m_cmsTemplateMutex.lock();
-        m_cmsTemplate->send(&messageCreator);
-        m_cmsTemplateMutex.unlock();
+        cmsTemplateMutex.lock();
+        cmsTemplate->send(&messageCreator);
+        cmsTemplateMutex.unlock();
         errorCode = CMS_SUCCESS;
     } catch (cms::CMSException& ex) {
-        m_cmsTemplateMutex.unlock();
+        cmsTemplateMutex.unlock();
         errorCode = CMS_ERROR_CAUGHT_CMS_EXCEPTION;
     }
 }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/Sender.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/Sender.h?rev=1419565&r1=1419564&r2=1419565&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/Sender.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/examples/cmstemplate-stress/Sender.h Mon
Dec 10 16:30:59 2012
@@ -30,8 +30,8 @@ namespace cmstemplate {
     class Sender {
     private:
 
-        decaf::util::concurrent::Mutex m_cmsTemplateMutex;
-        activemq::cmsutil::CmsTemplate* m_cmsTemplate;
+        decaf::util::concurrent::Mutex cmsTemplateMutex;
+        activemq::cmsutil::CmsTemplate* cmsTemplate;
 
     private:
 



Mime
View raw message