You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by JRR <jr...@cisco.com> on 2011/09/29 01:55:41 UTC

ActiveMQCPP::initializeLibrary() usage

Greetings all,

I have inherited some AMQ CPP client code. Recently we started seeing random
crashes when ActiveMQCPP::initializeLibrary() was being invoked. These
crashes do not always occur.

I used [gdb] and the information relating to this crash is as follows:

------------------------------------------------------------

------------------------------------------------------------

I have started reading through the AMQ CMS CPP documentation, but I don't
see any documentation for the initializeLibrary() method.

However, I do see in code examples, that this initializeLibrary() method is
being invoked as one of the first operations in main().

In the code that I've inheritted, the AMQ client code is abstracted way down
in a helper class and they
invoke the initializeLibrary() every time they are getting read to make a
connection to the broker.

I have a theory that initializeLibrary() should be invoked once and only
once. Moreover to make matters
worse, its possible for multile instances of one of our client AMQ objects
to execute at the same time, since we are a multi-threaded SMP system.

I see a comment in our code above the call that simply says:
        // initializeLibrary() is thread-safe.
however I haven't seen any documentation to prove or disprove this, nor have
I found any documentation to explain how the initializeLibrary() method
should be used.

Can anyone point out documentation for this method?

Thank you in advance for your help,

-=John

--
View this message in context: http://activemq.2283324.n4.nabble.com/ActiveMQCPP-initializeLibrary-usage-tp3853754p3853754.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: ActiveMQCPP::initializeLibrary() usage

Posted by JRR <jr...@cisco.com>.
Thanks for the pointer.

I did find that bit of documentation, but wasn't really satisfied with it.
It didn't state if this was something to call only once, although I agree it
could be assumed because of the name.

Your suggestions are in line with what I am currently attempting -- so my
idea isn't crazy! :)

Thank you for the help,

-=John

--
View this message in context: http://activemq.2283324.n4.nabble.com/ActiveMQCPP-initializeLibrary-usage-tp3853754p3856861.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: ActiveMQCPP::initializeLibrary() usage

Posted by spam trap <no...@spamgourmet.com>.
On Wed, 28 Sep 2011 16:55:41 -0700 (PDT), JRR
<jr...@cisco.com> wrote:

>Greetings all,
>
>I have inherited some AMQ CPP client code. Recently we started seeing random
>crashes when ActiveMQCPP::initializeLibrary() was being invoked. These
>crashes do not always occur.
>
>I used [gdb] and the information relating to this crash is as follows:
>
>------------------------------------------------------------
>
>------------------------------------------------------------
>
>I have started reading through the AMQ CMS CPP documentation, but I don't
>see any documentation for the initializeLibrary() method.
>
>However, I do see in code examples, that this initializeLibrary() method is
>being invoked as one of the first operations in main().
>
>In the code that I've inheritted, the AMQ client code is abstracted way down
>in a helper class and they
>invoke the initializeLibrary() every time they are getting read to make a
>connection to the broker.
>
>I have a theory that initializeLibrary() should be invoked once and only
>once. Moreover to make matters
>worse, its possible for multile instances of one of our client AMQ objects
>to execute at the same time, since we are a multi-threaded SMP system.
>
>I see a comment in our code above the call that simply says:
>        // initializeLibrary() is thread-safe.
>however I haven't seen any documentation to prove or disprove this, nor have
>I found any documentation to explain how the initializeLibrary() method
>should be used.
>
>Can anyone point out documentation for this method?

It's mentioned in the reference guide:
<http://activemq.apache.org/cms/api_docs/activemqcpp-3.2.5/html/classactivemq_1_1library_1_1_active_m_q_c_p_p.html#ab5b19bf0ceea3b2c32de1cef256da397>

As a general principle only assume that a method is thread safe iff
the documentation says so.  The default case is always to assume
things are not thread safe.  

Your problem could easily be caused by a race condition so I would
delete the comment and make it thread safe.  And I would recommend
only calling it once.  It can't do any harm.