[rabbitmq-discuss] py-amqplib basic_consume

tsuraan tsuraan at gmail.com
Fri Nov 21 22:09:36 GMT 2008


Ok, so now I'm trying to get basic_consume to work, and it's behaving
very strangely.  As before, I first run a producer that puts 1000
messages into a queue called toshred.  Once that has run, I run my new
consumer code, which just prints that it got something to consume.  It
doesn't acknowledge the message, it doesn't do anything the slightest
bit useful.  However, it does appear to devour messages like mad.
Every time I run this "consumer", it calls the consume method once,
but over 200 messages will be gone from the toshred queue (as
determined by a passive declaration of that queue).  If I run the
consumer first, and then put messages in the toshred queue, all but
five messages are enqueued, and the consumer exits after the first
call to consume.

Two questions: why are messages being removed from the queue?  It
doesn't seem like any messages are being acknowledged, so I wouldn't
expect any messages to be dequeued.  Also, what is the expected usage
for basic_consume?  Do you call it and channel.wait() in a loop, in
the same way that basic_get is used?

Consumer code:

import amqplib.client_0_8 as A

def consume(msg):
  print 'consuming', msg

def main():
  conn = A.Connection('localhost', userid='tsuraan', password='tsuraan')
  chan = conn.channel()

  chan.basic_consume('toshred', no_ack=True, callback=consume)
  print 'waiting'
  chan.wait()
  chan.close()
  conn.close()

if __name__ == "__main__":
  main()




More information about the rabbitmq-discuss mailing list