[rabbitmq-discuss] are multiple threads per connection ok for java api?

Michael Klishin michael.s.klishin at gmail.com
Fri Jul 8 16:16:29 BST 2011

2011/7/8 Jim Irrer <irrer at umich.edu>

> For the Java client API, the RabbitMQ documentation says that
> a single channel should not be used by more than one thread, but
> it does not explicitly say anything about connections.
AMQP assumes that one connection is typically used by more than one channel.

> Is it ok to have multiple threads (each with their own channel)
> sharing the same connection?

if channels are not shared between threads, then yes.

> Is there some advantage (performance
> or otherwise) to using a single connection verses multiple ones?

If all connections use the same credentials and connect to the same
broker/vhost, then no
(this should read: in vast majority of cases, no).

>  BTW - I'm assuming that each connection corresponds to a
> socket, and so opening lots of them consumes a somewhat limited
> system resource.

Long story short, this is true. Each connection has a frame handler that
opens a new socket.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20110708/a5323b43/attachment.htm>

More information about the rabbitmq-discuss mailing list