Hi Ale

On 11/9/09, Ale <peralta.alejan...@gmail.com> wrote:
> I've been trying to get a consumer to listen to two channels using
> LoopingCall: http://dpaste.com/hold/118305/. The code is modified from
> the original examples.

LoopingCall is meant for situations where you need to run something at
periodic intervals, however things like peeking from a queue, are
better handled by using events. The DeferredQueue provides an
event-driven mechanism for using queues, a call to get will return a
Deferred that will be fired when there's data in the queue (by calling

> What I wanted to achieve was to listen to
> different queues asynchronously (on one channel each queue).

You don't need separate channels for using more than one queue. Queues
are global to the broker (more specifically, to the virtual host in
the broker), however consumers are not shared between channels or
connections, though.

> The code which I sent both queues are on the same exchange.

I modified the last snippet I sent, and added another set of
(exchange, queue, consumer), but for a fanout exchange in this case:

> Is this ok? Is there a better way? Should I use threads here?

Whenever you feel the temptation of using threads, remember they are
only needed for blocking code :-) Most of the time you can achieve the
same rewriting your code using timed events.

> Another question I've is what about terminating the connection:
> How should I end the connection without sending the STOP message?

It depends on how you want it to be terminated :-) You can either keep
a counter or send a special message (like STOP).

Hope that helped.


Mailing list: https://launchpad.net/~txamqp-user
Post to     : txamqp-user@lists.launchpad.net
Unsubscribe : https://launchpad.net/~txamqp-user
More help   : https://help.launchpad.net/ListHelp

Reply via email to