[rabbitmq-discuss] Question about Connections and Channels

Emile Joubert emile at rabbitmq.com
Wed Dec 22 17:41:30 GMT 2010

Hi Thadeu,

Your project sounds interesting. If I understand your question correctly 
you want to know if you should be using one connection with many 
channels, or many connections each with a single channel.

A possibly relevant consideration is that if the broker needs to apply 
backpressure because of an overactive producer then all the channels 
sharing a connection with that producer will be blocked. Channels that 
can't tolerate this risk should have a connection to themselves. For the 
same reason you may want to separate producers and consumers to use 
different connections.

I would expect it to be more convenient for you to have an AMQP client 
in each JVM and therefore use a connection per JVM. AMQP connections are 
cheap resources and you need not try to conserve them. Brokers with tens 
of thousands of connections are not unheard of.

On 19/12/10 13:20, Thadeu Russo wrote:
> Hi,
> I need to architect a Java application using rabbitmq as its message
> broker. It is a distributed application and the message broker will play
> the role of connect the JVMs. Basically, each JVM has sets of objects
> (currently they are grouped by host:port) that can change messages to
> other objects in other groups in other virtual machines (there is a 1:1
> bi-directional relationship between groups of objects in different JVMs).
> The idea of use the broker is to avoid the number of tcp ports I have to
> open and also to take advantage of the message delivery guaranties.
> The design is simple: each group of objects will have an exchange and 2
> queues (incoming and outcoming) to change messages.
> I would like to know if you guys advise the following configuration
> regarding rabbitmq:
> 1- Have 1 connection per JVM
> 2- Have multiple channels to that connection. Each channel will be
> associated with those 2 queues
> What is concerning me is: the number of sends/receives per channel is
> high (about 5k/second). Should I have multiple connections (like a
> pool), or it is ok to use just 1 connection? If I have a pool of
> connections, I understand they will share the same tcp port, and I could
> not see any difference in using a single Connection.

The broker port will be same for each of multiple connections, but the 
peer port will typically be random. The difference is that connections 
with a single channel can fail and block without affecting other 



More information about the rabbitmq-discuss mailing list