← Back to team overview

txamqp-user team mailing list archive

Re: How do I subscribe to a queue in txamqp?

 

Hi,

On Tue, Oct 12, 2010 at 4:15 AM, Jithu Menon <jithu.menon@xxxxxxxxx> wrote:
> Hi,
>  I'm very new to txamqp and was wondering if there was an obvious way
> to subscribe to a queue that I simply couldn't see. Almost all examples
> for getting messages from a queue I've seen involves calling queue.get() (i.e. We are polling).

you're not polling, you're waiting for I/O.
yield'ing queue.get in fact means "register a deferred and fire it when there's
some data"... so is already a callback :)

if you do: d = queue.get() and then d.addCallback(fetchdata), the fetchdata
function will be called when some data is ready.
By using yield and the inlineCallbacks decorator you're doing the same
thing, but without creating a callBack chain...

regards,
matteo



References