qpid-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rafael Schloming <rafa...@redhat.com>
Subject Re: correct way to connect and close in python?
Date Thu, 01 Oct 2009 18:10:54 GMT
mARK bLOORE wrote:
> I am using the Qpid Python client library, with the 0.9 spec.  I have
> seen code that connects in various ways, and I have had trouble
> disconnecting cleanly.
> I connect like so:
>     client = Client(host, port, qpid.spec.load(amqp_spec), vhost='/test')
>     client.start({"LOGIN": 'guest', "PASSWORD": 'guest'})

I recommend dropping the spec argument, it should be found automatically.

>     channel = client.channel(1)
>     channel.channel_open()
> I then proceed to publish or subscribe without apparent difficulty.
> At the end I do this:
>     channel.basic_cancel(reply.consumer_tag)   # If I had called basic_consume.
>     channel.channel_close()
>     client.close()
> As I described in another message, this often results in lost messages
> or acknowledgments, unless I put a sleep before the shutdown sequence.
>  Am I doing something wrong?

Try doing this before doing client.close():


FYI, the code you're using is quite old and fairly 
undocumented/unsupported at this point. If you can you should consider 
using one of the newer python clients. At the moment that would require 
switching to the C++ broker since they're all based on the 0-10 
protocol, however the Java broker will have 0-10 support soon if Java is 
a requirement for you on the server side.


Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org

View raw message