You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2013/02/11 18:29:58 UTC
svn commit: r1444890 -
/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp
Author: tabish
Date: Mon Feb 11 17:29:57 2013
New Revision: 1444890
URL: http://svn.apache.org/r1444890
Log:
improve the thread naming for the Connection executor's threads.
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=1444890&r1=1444889&r2=1444890&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 Mon Feb 11 17:29:57 2013
@@ -93,21 +93,23 @@ namespace core{
class ConnectionThreadFactory : public ThreadFactory {
private:
- Pointer<Transport> transport;
+ std::string connectionId;
public:
- ConnectionThreadFactory(Pointer<Transport> transport) : transport(transport) {
- if (transport == NULL) {
- throw NullPointerException(__FILE__, __LINE__, "Transport cannot be null");
+ ConnectionThreadFactory(std::string connectionId) : connectionId(connectionId) {
+ if (connectionId.empty()) {
+ throw NullPointerException(__FILE__, __LINE__, "Connection Id must be set.");
}
}
virtual ~ConnectionThreadFactory() {}
virtual Thread* newThread(decaf::lang::Runnable* runnable) {
- Thread* thread = new Thread(runnable,
- std::string("ActiveMQ Connection Executor: ") + transport->getRemoteAddress());
+ static std::string prefix = "ActiveMQ Connection Executor: ";
+
+ std::string name = prefix + connectionId;
+ Thread* thread = new Thread(runnable, name);
return thread;
}
@@ -245,14 +247,16 @@ namespace core{
this->connectionInfo.reset(new ConnectionInfo());
this->brokerInfoReceived.reset(new CountDownLatch(1));
- this->executor.reset(
- new ThreadPoolExecutor(1, 1, 5, TimeUnit::SECONDS,
- new LinkedBlockingQueue<Runnable*>(), new ConnectionThreadFactory(transport)));
-
// Generate a connectionId
std::string uniqueId = CONNECTION_ID_GENERATOR.generateId();
decaf::lang::Pointer<ConnectionId> connectionId(new ConnectionId());
connectionId->setValue(uniqueId);
+
+ this->executor.reset(
+ new ThreadPoolExecutor(1, 1, 5, TimeUnit::SECONDS,
+ new LinkedBlockingQueue<Runnable*>(),
+ new ConnectionThreadFactory(connectionId->toString())));
+
this->connectionInfo->setConnectionId(connectionId);
this->scheduler.reset(new Scheduler(std::string("ActiveMQConnection[")+uniqueId+"] Scheduler"));
this->scheduler->start();
@@ -263,7 +267,7 @@ namespace core{
synchronized(&onExceptionLock) {
this->scheduler->shutdown();
this->executor->shutdown();
- this->executor->awaitTermination(1, TimeUnit::MINUTES);
+ this->executor->awaitTermination(10, TimeUnit::MINUTES);
}
}
AMQ_CATCHALL_NOTHROW()
@@ -455,13 +459,13 @@ ActiveMQConnection::ActiveMQConnection(c
////////////////////////////////////////////////////////////////////////////////
ActiveMQConnection::~ActiveMQConnection() {
- try {
- try {
- this->close();
- }
- AMQ_CATCHALL_NOTHROW()
+ try {
+ this->close();
+ }
+ AMQ_CATCHALL_NOTHROW()
+ try {
// This must happen even if exceptions occur in the Close attempt.
delete this->config;
}
@@ -476,7 +480,8 @@ void ActiveMQConnection::addDispatcher(c
this->config->dispatchers.put(consumer, dispatcher);
}
}
- AMQ_CATCH_ALL_THROW_CMSEXCEPTION()}
+ AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
+}
////////////////////////////////////////////////////////////////////////////////
void ActiveMQConnection::removeDispatcher(const decaf::lang::Pointer<ConsumerId>& consumer) {
@@ -486,7 +491,8 @@ void ActiveMQConnection::removeDispatche
this->config->dispatchers.remove(consumer);
}
}
- AMQ_CATCH_ALL_THROW_CMSEXCEPTION()}
+ AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
+}
////////////////////////////////////////////////////////////////////////////////
cms::Session* ActiveMQConnection::createSession() {