qpid-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Schlauch <jason.schla...@gmail.com>
Subject Re: Interaction of pthreads and Qpid client library
Date Thu, 18 Feb 2010 13:32:50 GMT
On Wed, Feb 17, 2010 at 5:26 PM, Birdsall, Dave <dave.birdsall@hp.com> wrote:
> Any gotchas?

I've used boost::threads with the QPID c++ client library and the
library appears to play nicely with threads.

A typical arrangement would be to have a single connection which
spawns multiple sessions; each thread will usually "own" a single
session object.  A subscription manager can be used on top of the
session to handle routing messages to your threads processing
function.

The only gotcha (at least with 0.5, possibly with later releases) is
with the non-blocking subscriptionmanager start() method.  Don't use
it.  You can't catch exceptions that the library generates using that
method. Things like the "connection closed" exception will not find a
handler and will call std::terminate on your program.  Don't design
your program around the start() method and instead plan on using your
own thread with the blocking run() method.

I recommend using boost::thread over pthreads since the latter will
require you to figure out how to shoehorn c++ functions into c style
function pointers that pthreads expects.  There are certainly examples
of how to do this on the Google, but you may as well let boost take
care of it for you.

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Mime
View raw message