You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by Ashok P <as...@gmail.com> on 2008/12/27 08:00:10 UTC
AMQCPP - CMSException is not getting caught by base class
std::exception.
I am upgrading CPP libary 2.1.1 to AMQCPP 2.2.2, and using
fuse-message-broker-5.2.0.1.
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().
Ex:
virtual void run() {
try {
// Create a ConnectionFactory
auto_ptr<ConnectionFactory> connectionFactory(
ConnectionFactory::createCMSConnectionFactory( brokerURI )
);
// Create a Connection
connection = connectionFactory->createConnection();
connection->start();
connection->setExceptionListener(this);
// Create a Session
if( this->sessionTransacted == true ) {
session = connection->createSession(
Session::SESSION_TRANSACTED );
} else {
session = connection->createSession(
Session::AUTO_ACKNOWLEDGE );
}
// 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
Queue
consumer = session->createConsumer( destination );
consumer->setMessageListener( this );
std::cout.flush();
std::cerr.flush();
// Indicate we are ready for messages.
latch.countDown();
// Wait while asynchronous messages come in.
doneLatch.await( waitMillis );
} catch (std::exception& e) {
//e.printStackTrace();
printf(e.what());
printf( "Std Exception at Consumer:");
}catch(cms::CMSException& e) {
// Indicate we are ready for messages.
latch.countDown();
printf("cms Exception occurred. Consumer.\n");
e.printStackTrace();
}
}
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: http://www.nabble.com/AMQCPP---CMSException-is-not-getting-caught-by-base-class-std%3A%3Aexception.-tp21182080p21182080.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
Re: AMQCPP - CMSException is not getting caught by base class
std::exception.
Posted by Ashok P <as...@gmail.com>.
Thanks Tim.
I created Jira issue for this -
https://issues.apache.org/activemq/browse/AMQCPP-218.
//Ashok
Timothy Bish wrote:
>
> Please feel free to create a Jira issue to document the potential bug
> you have uncovered. This will ensure that it doesn't get lost and that
> someone will eventually take a look at it.
>
> Regards
> Tim.
>
> On Fri, 2008-12-26 at 23:00 -0800, Ashok P wrote:
>> I am upgrading CPP libary 2.1.1 to AMQCPP 2.2.2, and using
>> fuse-message-broker-5.2.0.1.
>>
>> 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().
>>
>> Ex:
>> virtual void run() {
>>
>> try {
>>
>> // Create a ConnectionFactory
>> auto_ptr<ConnectionFactory> connectionFactory(
>> ConnectionFactory::createCMSConnectionFactory( brokerURI
>> )
>> );
>>
>> // Create a Connection
>> connection = connectionFactory->createConnection();
>> connection->start();
>> connection->setExceptionListener(this);
>>
>> // Create a Session
>> if( this->sessionTransacted == true ) {
>> session = connection->createSession(
>> Session::SESSION_TRANSACTED );
>> } else {
>> session = connection->createSession(
>> Session::AUTO_ACKNOWLEDGE );
>> }
>>
>> // 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
>> Queue
>> consumer = session->createConsumer( destination );
>>
>> consumer->setMessageListener( this );
>>
>> std::cout.flush();
>> std::cerr.flush();
>>
>> // Indicate we are ready for messages.
>> latch.countDown();
>>
>> // Wait while asynchronous messages come in.
>> doneLatch.await( waitMillis );
>>
>> } catch (std::exception& e) {
>> //e.printStackTrace();
>> printf(e.what());
>> printf( "Std Exception at Consumer:");
>> }catch(cms::CMSException& e) {
>>
>> // Indicate we are ready for messages.
>> latch.countDown();
>> printf("cms Exception occurred. Consumer.\n");
>>
>> e.printStackTrace();
>> }
>> }
>>
>> 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.
>>
>>
> --
> Tim Bish
> http://fusesource.com
> http://timbish.blogspot.com/
>
>
>
>
>
--
View this message in context: http://www.nabble.com/AMQCPP---CMSException-is-not-getting-caught-by-base-class-std%3A%3Aexception.-tp21182080p21213692.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
Re: AMQCPP - CMSException is not getting caught by base class
std::exception.
Posted by Timothy Bish <ta...@gmail.com>.
Please feel free to create a Jira issue to document the potential bug
you have uncovered. This will ensure that it doesn't get lost and that
someone will eventually take a look at it.
Regards
Tim.
On Fri, 2008-12-26 at 23:00 -0800, Ashok P wrote:
> I am upgrading CPP libary 2.1.1 to AMQCPP 2.2.2, and using
> fuse-message-broker-5.2.0.1.
>
> 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().
>
> Ex:
> virtual void run() {
>
> try {
>
> // Create a ConnectionFactory
> auto_ptr<ConnectionFactory> connectionFactory(
> ConnectionFactory::createCMSConnectionFactory( brokerURI )
> );
>
> // Create a Connection
> connection = connectionFactory->createConnection();
> connection->start();
> connection->setExceptionListener(this);
>
> // Create a Session
> if( this->sessionTransacted == true ) {
> session = connection->createSession(
> Session::SESSION_TRANSACTED );
> } else {
> session = connection->createSession(
> Session::AUTO_ACKNOWLEDGE );
> }
>
> // 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
> Queue
> consumer = session->createConsumer( destination );
>
> consumer->setMessageListener( this );
>
> std::cout.flush();
> std::cerr.flush();
>
> // Indicate we are ready for messages.
> latch.countDown();
>
> // Wait while asynchronous messages come in.
> doneLatch.await( waitMillis );
>
> } catch (std::exception& e) {
> //e.printStackTrace();
> printf(e.what());
> printf( "Std Exception at Consumer:");
> }catch(cms::CMSException& e) {
>
> // Indicate we are ready for messages.
> latch.countDown();
> printf("cms Exception occurred. Consumer.\n");
>
> e.printStackTrace();
> }
> }
>
> 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.
>
>
--
Tim Bish
http://fusesource.com
http://timbish.blogspot.com/