Return-Path: Delivered-To: apmail-incubator-qpid-users-archive@locus.apache.org Received: (qmail 19921 invoked from network); 4 Mar 2008 03:05:02 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 4 Mar 2008 03:05:02 -0000 Received: (qmail 34815 invoked by uid 500); 4 Mar 2008 03:04:58 -0000 Delivered-To: apmail-incubator-qpid-users-archive@incubator.apache.org Received: (qmail 34797 invoked by uid 500); 4 Mar 2008 03:04:58 -0000 Mailing-List: contact qpid-users-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: qpid-users@incubator.apache.org Delivered-To: mailing list qpid-users@incubator.apache.org Delivered-To: moderator for qpid-users@incubator.apache.org Received: (qmail 75965 invoked by uid 99); 4 Mar 2008 02:02:33 -0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of Brent.Villalobos@pdi.dreamworks.com designates 64.173.252.40 as permitted sender) Message-ID: <47CCAD9E.7040103@pdi.dreamworks.com> Date: Mon, 03 Mar 2008 18:02:06 -0800 From: Brent Villalobos Organization: DreamWorks Animation, SKG User-Agent: Thunderbird 2.0.0.9 (X11/20071031) MIME-Version: 1.0 To: qpid-users@incubator.apache.org Subject: Python: How to consume one message? Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org This is my first time using QPID and I'm trying to write a simple producer/consumer setup. My producer is sending messages and the QPID broker is receiving and storing them just fine. However, I want a consumer to process one message at a time. My consumer code looks something like this: host="localhost" port=5672 amqp_spec="/usr/pic1/qpid-1.0-all/Python/specs/amqp.0-8.xml" user="guest" password="guest" client = Client(host, port, qpid.spec.load(amqp_spec)) client.start({"LOGIN": user, "PASSWORD": password}) channel = client.channel(1) channel.channel_open() reply = channel.basic_consume(queue="message_queue", no_ack=True) queue = client.queue(reply.consumer_tag) msg = queue.get(timeout=1) print "Consumer gets this message: ", msg.content.body channel.channel_close() I have a broker that has 10 messages on it. When I run the consumer I get this: Consumer gets this message: I am a test message Unhandled exception in thread started by Error in sys.excepthook: Original exception was: When I run the consumer again, this is the output: Traceback (most recent call last): File "./consumer.py", line 31, in ? msg = queue.get(timeout=1) File "/usr/pic1/qpid-1.0-all/Python/python/qpid/queue.py", line 38, in get result = BaseQueue.get(self, block, timeout) File "/rel/lang/python/2.4.4-6/lib/python2.4/Queue.py", line 127, in get raise Empty Queue.Empty What am I doing wrong that all the messages in my queue are wiped out after I consume one message? -Brent V.