activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spam trap <>
Subject Re: ActiveMQCPP::initializeLibrary() usage
Date Thu, 29 Sep 2011 09:08:12 GMT
On Wed, 28 Sep 2011 16:55:41 -0700 (PDT), JRR
<> 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:

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.

View raw message