Author: tabish
Date: Fri Nov 9 12:16:05 2007
New Revision: 593640
URL: http://svn.apache.org/viewvc?rev=593640&view=rev
Log:
http://issues.apache.org/activemq/browse/AMQCPP-103
Modified:
activemq/activemq-cpp/trunk/src/main/activemq/core/ActiveMQConnection.cpp
activemq/activemq-cpp/trunk/src/main/activemq/core/ActiveMQConnectionFactory.cpp
activemq/activemq-cpp/trunk/src/main/activemq/core/ActiveMQConsumer.cpp
activemq/activemq-cpp/trunk/src/main/activemq/core/ActiveMQProducer.cpp
Modified:
activemq/activemq-cpp/trunk/src/main/activemq/core/ActiveMQConnection.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/core/ActiveMQConnection.cpp?rev=593640&r1=593639&r2=593640&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/core/ActiveMQConnection.cpp
(original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/core/ActiveMQConnection.cpp
Fri Nov 9 12:16:05 2007
@@ -35,8 +35,7 @@
using namespace std;
////////////////////////////////////////////////////////////////////////////////
-ActiveMQConnection::ActiveMQConnection(ActiveMQConnectionData* connectionData)
-{
+ActiveMQConnection::ActiveMQConnection(ActiveMQConnectionData* connectionData)
{
this->connectionData = connectionData;
this->started = false;
this->closed = false;
@@ -49,8 +48,7 @@
}
////////////////////////////////////////////////////////////////////////////////
-ActiveMQConnection::~ActiveMQConnection()
-{
+ActiveMQConnection::~ActiveMQConnection() {
try {
close();
}
@@ -60,8 +58,8 @@
////////////////////////////////////////////////////////////////////////////////
void ActiveMQConnection::addDispatcher( connector::ConsumerInfo* consumer,
- Dispatcher* dispatcher )
-{
+ Dispatcher* dispatcher ) {
+
// Add the consumer to the map.
synchronized( &dispatchers ) {
dispatchers.setValue( consumer->getConsumerId(), dispatcher );
@@ -78,19 +76,19 @@
}
////////////////////////////////////////////////////////////////////////////////
-cms::Session* ActiveMQConnection::createSession() throw ( cms::CMSException )
-{
+cms::Session* ActiveMQConnection::createSession() throw ( cms::CMSException ) {
try {
return createSession( Session::AUTO_ACKNOWLEDGE );
}
AMQ_CATCH_RETHROW( ActiveMQException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ActiveMQException )
AMQ_CATCHALL_THROW( ActiveMQException )
}
////////////////////////////////////////////////////////////////////////////////
cms::Session* ActiveMQConnection::createSession(
- cms::Session::AcknowledgeMode ackMode ) throw ( cms::CMSException )
-{
+ cms::Session::AcknowledgeMode ackMode ) throw ( cms::CMSException ) {
+
try {
// Create the session instance.
@@ -112,12 +110,13 @@
return session;
}
AMQ_CATCH_RETHROW( ActiveMQException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ActiveMQException )
AMQ_CATCHALL_THROW( ActiveMQException )
}
////////////////////////////////////////////////////////////////////////////////
-std::string ActiveMQConnection::getClientID() const
-{
+std::string ActiveMQConnection::getClientID() const {
+
if( closed ) {
return "";
}
@@ -163,42 +162,53 @@
}
}
AMQ_CATCH_RETHROW( ActiveMQException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ActiveMQException )
AMQ_CATCHALL_THROW( ActiveMQException )
}
////////////////////////////////////////////////////////////////////////////////
-void ActiveMQConnection::start() throw ( cms::CMSException )
-{
- // This starts or restarts the delivery of all incomming messages
- // messages delivered while this connection is stopped are dropped
- // and not acknowledged.
- started = true;
+void ActiveMQConnection::start() throw ( cms::CMSException ) {
+ try{
- // Start all the sessions.
- std::vector<ActiveMQSession*> sessions = activeSessions.toArray();
- for( unsigned int ix=0; ix<sessions.size(); ++ix ) {
- sessions[ix]->start();
+ // This starts or restarts the delivery of all incomming messages
+ // messages delivered while this connection is stopped are dropped
+ // and not acknowledged.
+ started = true;
+
+ // Start all the sessions.
+ std::vector<ActiveMQSession*> sessions = activeSessions.toArray();
+ for( unsigned int ix=0; ix<sessions.size(); ++ix ) {
+ sessions[ix]->start();
+ }
}
+ AMQ_CATCH_RETHROW( ActiveMQException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ActiveMQException )
+ AMQ_CATCHALL_THROW( ActiveMQException )
}
////////////////////////////////////////////////////////////////////////////////
-void ActiveMQConnection::stop() throw ( cms::CMSException )
-{
- // Once current deliveries are done this stops the delivery of any
- // new messages.
- started = false;
-
- Iterator<ActiveMQSession*>* iter = activeSessions.iterator();
- while( iter->hasNext() ){
- iter->next()->stop();
+void ActiveMQConnection::stop() throw ( cms::CMSException ) {
+
+ try {
+
+ // Once current deliveries are done this stops the delivery of any
+ // new messages.
+ started = false;
+
+ Iterator<ActiveMQSession*>* iter = activeSessions.iterator();
+ while( iter->hasNext() ){
+ iter->next()->stop();
+ }
+ delete iter;
}
- delete iter;
+ AMQ_CATCH_RETHROW( ActiveMQException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ActiveMQException )
+ AMQ_CATCHALL_THROW( ActiveMQException )
}
////////////////////////////////////////////////////////////////////////////////
void ActiveMQConnection::onConsumerMessage( connector::ConsumerInfo* consumer,
- core::ActiveMQMessage* message )
-{
+ core::ActiveMQMessage* message ) {
try {
if( connectionData == NULL) {
@@ -252,8 +262,8 @@
////////////////////////////////////////////////////////////////////////////////
void ActiveMQConnection::removeSession( ActiveMQSession* session )
- throw ( cms::CMSException )
-{
+ throw ( cms::CMSException ) {
+
try {
// Remove this session from the set of active sessions.
@@ -262,5 +272,6 @@
}
}
AMQ_CATCH_RETHROW( ActiveMQException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ActiveMQException )
AMQ_CATCHALL_THROW( ActiveMQException )
}
Modified:
activemq/activemq-cpp/trunk/src/main/activemq/core/ActiveMQConnectionFactory.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/core/ActiveMQConnectionFactory.cpp?rev=593640&r1=593639&r2=593640&view=diff
==============================================================================
---
activemq/activemq-cpp/trunk/src/main/activemq/core/ActiveMQConnectionFactory.cpp
(original)
+++
activemq/activemq-cpp/trunk/src/main/activemq/core/ActiveMQConnectionFactory.cpp
Fri Nov 9 12:16:05 2007
@@ -142,7 +142,7 @@
ConnectorFactoryMap::getInstance()->lookup( wireFormat );
if( connectorfactory == NULL ) {
- throw NullPointerException(
+ throw ActiveMQException(
__FILE__, __LINE__,
"ActiveMQConnectionFactory::createConnection - "
"Connector for Wire Format not registered in Map" );
@@ -152,7 +152,7 @@
connector = connectorfactory->createConnector( *properties, transport
);
if( connector == NULL ) {
- throw NullPointerException(
+ throw ActiveMQException(
__FILE__, __LINE__,
"ActiveMQConnectionFactory::createConnection - "
"Failed to Create the Connector" );
Modified:
activemq/activemq-cpp/trunk/src/main/activemq/core/ActiveMQConsumer.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/core/ActiveMQConsumer.cpp?rev=593640&r1=593639&r2=593640&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/core/ActiveMQConsumer.cpp
(original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/core/ActiveMQConsumer.cpp Fri
Nov 9 12:16:05 2007
@@ -21,7 +21,7 @@
#include <decaf/lang/exceptions/IllegalArgumentException.h>
#include <decaf/util/Date.h>
#include <activemq/util/Config.h>
-#include <activemq/exceptions/ExceptionDefines.h>
+#include <activemq/exceptions/ActiveMQException.h>
#include <activemq/core/ActiveMQSession.h>
#include <activemq/core/ActiveMQMessage.h>
#include <cms/ExceptionListener.h>
@@ -32,17 +32,17 @@
using namespace activemq::core;
using namespace activemq::connector;
using namespace activemq::exceptions;
+using namespace decaf::lang;
using namespace decaf::lang::exceptions;
using namespace decaf::util;
using namespace decaf::util::concurrent;
////////////////////////////////////////////////////////////////////////////////
ActiveMQConsumer::ActiveMQConsumer( connector::ConsumerInfo* consumerInfo,
- ActiveMQSession* session )
-{
- if( session == NULL || consumerInfo == NULL )
- {
- throw NullPointerException(
+ ActiveMQSession* session ) {
+
+ if( session == NULL || consumerInfo == NULL ) {
+ throw ActiveMQException(
__FILE__, __LINE__,
"ActiveMQConsumer::ActiveMQConsumer - Init with NULL Session");
}
@@ -58,12 +58,10 @@
}
////////////////////////////////////////////////////////////////////////////////
-ActiveMQConsumer::~ActiveMQConsumer()
-{
- try
- {
- close();
+ActiveMQConsumer::~ActiveMQConsumer() {
+ try {
+ close();
delete consumerInfo;
}
AMQ_CATCH_NOTHROW( ActiveMQException )
@@ -72,10 +70,10 @@
////////////////////////////////////////////////////////////////////////////////
void ActiveMQConsumer::close()
- throw ( cms::CMSException )
-{
- try
- {
+ throw ( cms::CMSException ) {
+
+ try{
+
if( !closed ) {
// Identifies any errors encountered during shutdown.
@@ -118,37 +116,37 @@
}
}
AMQ_CATCH_RETHROW( ActiveMQException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ActiveMQException )
AMQ_CATCHALL_THROW( ActiveMQException )
}
////////////////////////////////////////////////////////////////////////////////
std::string ActiveMQConsumer::getMessageSelector() const
- throw ( cms::CMSException )
-{
- try
- {
+ throw ( cms::CMSException ) {
+
+ try {
// Fetch the Selector
return consumerInfo->getMessageSelector();
}
AMQ_CATCH_RETHROW( ActiveMQException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ActiveMQException )
AMQ_CATCHALL_THROW( ActiveMQException )
}
////////////////////////////////////////////////////////////////////////////////
-ActiveMQMessage* ActiveMQConsumer::dequeue(int timeout)
- throw ( cms::CMSException )
-{
- try
- {
- if( closed )
- {
- throw InvalidStateException(
+ActiveMQMessage* ActiveMQConsumer::dequeue( int timeout )
+ throw ( cms::CMSException ) {
+
+ try {
+
+ if( closed ) {
+ throw ActiveMQException(
__FILE__, __LINE__,
"ActiveMQConsumer::receive - This Consumer is closed" );
}
- synchronized( &unconsumedMessages )
- {
+ synchronized( &unconsumedMessages ) {
+
// Calculate the deadline
long long deadline = 0;
if (timeout > 0) {
@@ -160,8 +158,8 @@
// Wait until either the deadline is met, a message arrives, or
// we've closed.
- while( !closed && unconsumedMessages.empty() && timeout != 0 )
- {
+ while( !closed && unconsumedMessages.empty() && timeout != 0 )
{
+
if( timeout < 0 ) {
unconsumedMessages.wait();
} else if( timeout > 0 ) {
@@ -204,17 +202,17 @@
return NULL;
}
AMQ_CATCH_RETHROW( ActiveMQException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ActiveMQException )
AMQ_CATCHALL_THROW( ActiveMQException )
}
////////////////////////////////////////////////////////////////////////////////
-cms::Message* ActiveMQConsumer::receive() throw ( cms::CMSException )
-{
- try
- {
- if( closed )
- {
- throw InvalidStateException(
+cms::Message* ActiveMQConsumer::receive() throw ( cms::CMSException ) {
+
+ try{
+
+ if( closed ) {
+ throw ActiveMQException(
__FILE__, __LINE__,
"ActiveMQConsumer::receive - This Consumer is closed" );
}
@@ -239,18 +237,18 @@
return clonedMsg;
}
AMQ_CATCH_RETHROW( ActiveMQException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ActiveMQException )
AMQ_CATCHALL_THROW( ActiveMQException )
}
////////////////////////////////////////////////////////////////////////////////
cms::Message* ActiveMQConsumer::receive( int millisecs )
- throw ( cms::CMSException )
-{
- try
- {
- if( closed )
- {
- throw InvalidStateException(
+ throw ( cms::CMSException ) {
+
+ try {
+
+ if( closed ) {
+ throw ActiveMQException(
__FILE__, __LINE__,
"ActiveMQConsumer::receive - This Consumer is closed" );
}
@@ -275,18 +273,18 @@
return clonedMsg;
}
AMQ_CATCH_RETHROW( ActiveMQException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ActiveMQException )
AMQ_CATCHALL_THROW( ActiveMQException )
}
////////////////////////////////////////////////////////////////////////////////
cms::Message* ActiveMQConsumer::receiveNoWait()
- throw ( cms::CMSException )
-{
- try
- {
- if( closed )
- {
- throw InvalidStateException(
+ throw ( cms::CMSException ) {
+
+ try {
+
+ if( closed ) {
+ throw ActiveMQException(
__FILE__, __LINE__,
"ActiveMQConsumer::receive - This Consumer is closed" );
}
@@ -311,17 +309,17 @@
return clonedMsg;
}
AMQ_CATCH_RETHROW( ActiveMQException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ActiveMQException )
AMQ_CATCHALL_THROW( ActiveMQException )
}
////////////////////////////////////////////////////////////////////////////////
-void ActiveMQConsumer::setMessageListener( cms::MessageListener* listener )
-{
- try
- {
- if( closed )
- {
- throw InvalidStateException(
+void ActiveMQConsumer::setMessageListener( cms::MessageListener* listener ) {
+
+ try{
+
+ if( closed ) {
+ throw ActiveMQException(
__FILE__, __LINE__,
"ActiveMQConsumer::receive - This Consumer is closed" );
}
@@ -346,6 +344,7 @@
}
}
AMQ_CATCH_RETHROW( ActiveMQException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ActiveMQException )
AMQ_CATCHALL_THROW( ActiveMQException )
}
@@ -365,10 +364,10 @@
////////////////////////////////////////////////////////////////////////////////
void ActiveMQConsumer::afterMessageIsConsumed( ActiveMQMessage* message,
- bool messageExpired AMQCPP_UNUSED )
-{
- try
- {
+ bool messageExpired AMQCPP_UNUSED ) {
+
+ try{
+
if( !session->isClientAcknowledge() ) {
session->acknowledge( this, message );
}
@@ -380,18 +379,18 @@
destroyMessage( message );
}
AMQ_CATCH_RETHROW( ActiveMQException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ActiveMQException )
AMQ_CATCHALL_THROW( ActiveMQException )
}
////////////////////////////////////////////////////////////////////////////////
void ActiveMQConsumer::acknowledgeMessage( const ActiveMQMessage* message )
- throw ( cms::CMSException )
-{
- try
- {
- if( closed )
- {
- throw InvalidStateException(
+ throw ( cms::CMSException ) {
+
+ try{
+
+ if( closed ) {
+ throw ActiveMQException(
__FILE__, __LINE__,
"ActiveMQConsumer::receive - This Consumer is closed" );
}
@@ -402,14 +401,15 @@
session->acknowledge( this, const_cast<ActiveMQMessage*>(message) );
}
AMQ_CATCH_RETHROW( ActiveMQException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ActiveMQException )
AMQ_CATCHALL_THROW( ActiveMQException )
}
////////////////////////////////////////////////////////////////////////////////
-void ActiveMQConsumer::dispatch( DispatchData& data )
-{
- try
- {
+void ActiveMQConsumer::dispatch( DispatchData& data ) {
+
+ try {
+
ActiveMQMessage* message = data.getMessage();
// Don't dispatch expired messages, ack it and then destroy it
@@ -444,18 +444,18 @@
}
}
AMQ_CATCH_RETHROW( ActiveMQException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ActiveMQException )
AMQ_CATCHALL_THROW( ActiveMQException )
}
////////////////////////////////////////////////////////////////////////////////
void ActiveMQConsumer::purgeMessages() throw ( ActiveMQException )
{
- try
- {
- synchronized( &unconsumedMessages )
- {
- while( !unconsumedMessages.empty() )
- {
+ try {
+
+ synchronized( &unconsumedMessages ) {
+
+ while( !unconsumedMessages.empty() ) {
// destroy these messages if this is not a transacted
// session, if it is then the tranasction will clean
// the messages up.
@@ -464,26 +464,25 @@
}
}
AMQ_CATCH_RETHROW( ActiveMQException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ActiveMQException )
AMQ_CATCHALL_THROW( ActiveMQException )
}
////////////////////////////////////////////////////////////////////////////////
void ActiveMQConsumer::destroyMessage( ActiveMQMessage* message )
-throw ( ActiveMQException )
-{
+ throw ( ActiveMQException ) {
- try
- {
+ try {
/**
* Only destroy the message if the session is NOT transacted. If
* it is, the session will take care of it.
*/
- if( message != NULL && !session->isTransacted() )
- {
+ if( message != NULL && !session->isTransacted() ) {
delete message;
}
}
AMQ_CATCH_RETHROW( ActiveMQException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ActiveMQException )
AMQ_CATCHALL_THROW( ActiveMQException )
}
@@ -493,16 +492,15 @@
try{
- if( closed )
- {
- throw InvalidStateException(
+ if( closed ) {
+ throw ActiveMQException(
__FILE__, __LINE__,
"ActiveMQConsumer::onConnectorResourceClosed - "
"Producer Already Closed");
}
if( resource != consumerInfo ) {
- throw IllegalArgumentException(
+ throw ActiveMQException(
__FILE__, __LINE__,
"ActiveMQConsumer::onConnectorResourceClosed - "
"Unknown object passed to this callback");
@@ -512,5 +510,6 @@
this->close();
}
AMQ_CATCH_RETHROW( ActiveMQException )
+ AMQ_CATCH_EXCEPTION_CONVERT( Exception, ActiveMQException )
AMQ_CATCHALL_THROW( ActiveMQException )
}
Modified:
activemq/activemq-cpp/trunk/src/main/activemq/core/ActiveMQProducer.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/core/ActiveMQProducer.cpp?rev=593640&r1=593639&r2=593640&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/core/ActiveMQProducer.cpp
(original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/core/ActiveMQProducer.cpp Fri
Nov 9 12:16:05 2007
@@ -28,6 +28,7 @@
using namespace activemq::connector;
using namespace activemq::exceptions;
using namespace decaf::util;
+using namespace decaf::lang;
using namespace decaf::lang::exceptions;
////////////////////////////////////////////////////////////////////////////////