[rabbitmq-discuss] C client and thread safety

Jim Irrer irrer at umich.edu
Thu Jul 1 21:29:16 BST 2010

Greetings -

Firstly, I remain impressed with Rabbit as a group that can make solid,

I'm working with the RabbitMQ C client, and had a few questions
about thread safety.  In particular:

Must a socket returned by amqp_open_socket be exclusively
associated with one connection, or can it be used for multiple

Must a socket returned by amqp_open_socket be exclusively
used by one thread, or can it be used by multiple threads?

Must a connection returned by amqp_new_connection be exclusively
used to read from or write to one channel/queue, or is using multiple ok,
even in a multi-threaded environment.

If any of these can be used by multiple threads, is there a performance
advantage in reusing the same socket or connection, or is using multiple
ones better?

It looks like channels (created with amqp_channel_open) are identified by
integers chosen by the application and are associated with the connection.
means that it is the responsibility of the application to choose unique
properly close them, etc..   It would seem cleaner to pass a connection as a
single parameter to amqp_channel_open and have it return a pointer to a
and the list of channels would be maintained in the connection.

Also, it looks like amqp_new_connection uses 'calloc' to allocate
memory for a connection, but amqp_connection_close does not do
a 'free' to avoid the memory leak.  Maybe that was intentional, but if
not it should be changed.


- Jim

Jim Irrer     irrer at umich.edu       (734) 647-4409
University of Michigan Hospital Radiation Oncology
519 W. William St.             Ann Arbor, MI 48103
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20100701/52dfe08d/attachment.htm>

More information about the rabbitmq-discuss mailing list