← Back to team overview

txamqp-user team mailing list archive

Re: How do you listen to different queues asynchronously?

 

Hi Esteve,

First thanks a lot for replying my email.

Comments in-line.

2009/11/9 Esteve Fernandez <esteve.fernandez@xxxxxxxxx>:
[snip]
>> 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:
>
> http://dpaste.com/hold/118490/
>> 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.

I did tried to use gatherResults in other attempts but I was confused.

Help me understand:

gatherResults waits for all the deferreds to fire (or in this case for
all the functions in the list to return). But since the the functions
are working on loops waiting for events gatherResults wont return
until the producers send STOP and the consumers break the loop.

Is that right?

Am sorry if I ask this twisted question on the list but they are
closely related.

>
>> 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).
>

Yeah :-), I was thinking more of breaking the consumer loop because
I'm quiting my program and I want to end cleanly. Maybe using a global
boolean variable? Sending a STOP message from the consumer to
terminate that same process doesn't look right.

The idea is that I have a bunch of users in a "conversation" (sending
a receiving messages) and any of the users can leave the
"conversation" any time without disturbing others.

> Hope that helped.

Yes indeed it helped a lot.


Cheers,


-- 
Ale.



Follow ups

References