[rabbitmq-discuss] Design question: the ratio of queues to channels

Simon MacMullen simon at rabbitmq.com
Tue Jul 13 10:12:36 BST 2010


On 12/07/10 21:40, John Goodson wrote:
> I noticed in the looking over the examples that the ratio of channels to
> queue is almost one-to-one. In my applications I just open one channel
> and then create the queues I need using it.

Hi John. I'm not sure which examples you're talking about - your example 
code looks like Ruby though.

> Examples based code:
>
>      MQ.new.queue('1').subscribe ...
>      MQ.new.queue('2').subscribe ..
>      MQ.new.queue('2').publish ...
>
>
> My usage style:
>
>     amq = MQ.new
>     q1 = amq.queue('1')
>     q2 = amq.queue('2')
>
>     q1.subscribe ..
>     q2.subscribe ..
>     q2.publish ...
>
> Which approach is better and why?

The primary things that channels do are:

* Give scope to some errors
* Give scope to consumers
* Allow at most one operation at once

So with your approach you run the risk that a soft error (e.g. 
not-found) will close the single channel and take down everything. This 
may or may not be a concern.

Also, if your app is multithreaded it can still only perform one 
operation at once (although channels are not threadsafe in most clients 
anyway).

Of course, neither of these may be a concern to you.

Is that any clearer?

 > Are there any documents that I can
 > reference that give guidelines on this?

The best thing is the spec. Yeah, I know. One of the items on our very 
long todo list is a comprehensive overview of AMQP...

Cheers, Simon

-- 
Simon MacMullen
Staff Engineer, RabbitMQ
SpringSource, a division of VMware



More information about the rabbitmq-discuss mailing list