activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ashok P <>
Subject AMQCPP - CMSException is not getting caught by base class std::exception.
Date Sat, 27 Dec 2008 07:00:10 GMT

I am upgrading CPP libary 2.1.1 to AMQCPP 2.2.2, and using

My application is in C++ so it uses std::exception handler as generic. But
with AMQCPP 2.2.2 and 2.2.1, these handlers are not getting called though
cms:CMSException handlers get called.

I tested it using test application in AMQCPP library
<vs2005-activemq-example>. Here is consumer's run method from example. Put
your broker down, so you will get exception at CreateConnection().

 virtual void run() {

        try {

            // Create a ConnectionFactory
            auto_ptr<ConnectionFactory> connectionFactory(
                ConnectionFactory::createCMSConnectionFactory( brokerURI )

            // Create a Connection
            connection = connectionFactory->createConnection();

            // Create a Session
            if( this->sessionTransacted == true ) {
                session = connection->createSession(
            } else {
                session = connection->createSession(

            // Create the destination (Topic or Queue)
            if( useTopic ) {
                destination = session->createTopic( "TEST.FOO" );
            } else {
                destination = session->createQueue( "TEST.FOO" );

            // Create a MessageConsumer from the Session to the Topic or
            consumer = session->createConsumer( destination );

            consumer->setMessageListener( this );


            // Indicate we are ready for messages.

            // Wait while asynchronous messages come in.
            doneLatch.await( waitMillis );

		} catch (std::exception& e) {
			printf( "Std Exception at Consumer:");
		}catch(cms::CMSException& e) {

            // Indicate we are ready for messages.
	  printf("cms Exception occurred. Consumer.\n");


I am getting warning for this as expected in build:
warning C4286: 'cms::CMSException &' : is caught by base class
('std::exception &') on line 127

But the std::exception handler is not getting called though CMSException
handler excuted. As a base class  I believe that std:exception should get
called. This is working fine using 2.1.1 library, but not 2.2.1/2.2.2. 

I might be wrong, please correct me and help me sort out this problem.

View this message in context:
Sent from the ActiveMQ - Dev mailing list archive at

View raw message