Ah, of course. Sorry, I should have known that! Thanks for your help
On 13/09/2010 16:00, Gordon Sim wrote:
On 09/13/2010 03:57 PM, Chris Howard wrote:
Here is a simple python script that fetches a message from a queue:
import qpid.messaging
connection = qpid.messaging.Connection('amqp://localhost:5672')
connection.open()
session = connection.session()
receiver = session.receiver('myQueue; {create: receiver, delete: never,
mode: consume}')
request = receiver.fetch(10)
print request.content
connection.close()
I have another python script that puts a message onto this queue:
import qpid.messaging
connection = qpid.messaging.Connection('amqp://localhost:5672')
connection.open()
session = connection.session()
sender = session.sender('myQueue')
request = qpid.messaging.Message(content = 'ping')
sender.send(request)
connection.close()
I start the first script, and then start the second script. As expected,
the message is received and both scripts exit. However, if I then run
the first script again, the same message is received again. This is
probably just a misunderstanding on my part, but I would have expected
the message to be consumed the first time the script was run. Please
could someone explain why the message is not consumed and remains in the
queue.
You need to acknowledge that you have successfully received (and
processed) the message. E.g.
request = receiver.fetch(10)
print request.content
session.acknowledge() # acks all fetched messages
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:[email protected]
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:[email protected]