[rabbitmq-discuss] Multi-threading in c/c++

Eric J. Holtman eric at holtmans.com
Thu Feb 16 12:13:53 GMT 2012


I've been hoping to get rabbitmq integrated into some
of my applications.  I've read a few books and web
articles.  I've wrangled the source into compiling and
working under Windows.  The examples run fine.

I'm trying to figure out how to run under a multithreaded
environment.  As I understood it, the whole point of having
a multiplexed connection was so that I didn't have to
burn an actual TCP connection for every channel.

However, that doesn't seem to be how rabbitmq-c is
set up.

In fact, a recent question from the archives, answered
by Alan says:

> You have interpreted the documentation correctly:
> 
> amqp_connection_state_t, its socket, and all associated amqp_channel_t's
> must not be shared between threads.  Its ok to have separate instances of
> these objects used in different threads.

So, if I want to consume on 4 queues, and the natural
solution would be to have 4 threads doing a blocking
wait (like "run" in the amqp_consumer example), I have
to have a separate TCP connection for each one?

Also, I assume if I'm going to use a c++ wrapper like
amqpcpp or rabbitcpp I'm going to have the same issue,
since they're using rabbitmq-c as the lower layer?

Thanks,

Eric


More information about the rabbitmq-discuss mailing list