[rabbitmq-discuss] py-amqplib status messages

tsuraan tsuraan at gmail.com
Fri Nov 21 01:50:20 GMT 2008

How does py-amqplib return results to the user?  For example,
basic_publish has a mandatory flag, which says that if the server
cannot route a message, it gives an unroutable message back.  How does
the user of py-amqplib get this message?  It seems like every method
returns None all the time with the exception of basic_get, so how can
I get server responses?

The reason I ask is that if I do 1000 basic_publish calls, the first
several hundred (used to be ~600, closer to 800 with the latest hg
tip) messages get inserted, but the rest do not (this is the same
problem that I was having a month or so ago, but I finally got time to
pick this up again, so I'm starting fresh-ish).  The call is being
made a thousand times with messages whose bodies are the value of a
simple integer counter, and I never get any sort of failure report or
anything, but I really don't have any idea how to get status

Code samples:
message inserter, which is run first:

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

  for i in range(1000):
    m = A.Message(str(i), delivery_mode=2)
    chan.basic_publish(m, 'rawmsg', 'standard', mandatory=True, immediate=False)

if __name__ == "__main__":

message consumer, which is run after the inserter is run (I know
that's not realistic, but I want to know why I'm silently losing

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

  nums = []
  while True:
    msg = chan.basic_get("msgq", no_ack=True)
    if msg is None:
      print 'all done'
      print 'got message', msg.body

    dtag = msg.delivery_info['delivery_tag']

  print len(nums)

if __name__ == "__main__":

When the first program is run, it runs for a moment, and then exits
without any errors.  The second program is run, and it only gets a few
hundred messages.  The ids that it gets are always sequential numbers,
starting with 0.  It's as though the last couple of hundred messages
just never happened, although they were published.

More information about the rabbitmq-discuss mailing list