[rabbitmq-discuss] python client

Dmitriy Samovskiy dmitriy.samovskiy at cohesiveft.com
Fri Sep 7 20:05:02 BST 2007


Matthias,

Thanks for the link below - I saw that section before, but now I re-read 
it and was able to get it working.

Edwin,

The key is to use original amqp 0.8 xml spec, not the one in qpid trunk. 
Download link is at URL that Matthias provided below.

The code below does not raise an exception. I am just starting working 
with rabbitmq and I still don't understand all details of what this code 
does, but at least it works.

#----------------------------------

#!/usr/bin/python

QPID_PATH = '/usr/local/qpid-svn/qpid'

import sys, os, time
sys.path += [ QPID_PATH + '/python' ]

import qpid
from qpid.client import Client
from qpid.content import Content

client = Client("127.0.0.1", 5672, spec=qpid.spec.load('amqp0-8.xml'))
client.start({ 'LOGIN': 'guest', 'PASSWORD': 'guest'})

ch = client.channel(1)
ch.channel_open()
ch.queue_declare(queue="test1", exclusive=True)
ch.queue_bind(queue="test1", exchange="amq.direct", \ 
routing_key="test_key_1")

print 'Sending message "ping"...  ',
ch.basic_publish(routing_key="test_key_1", content=Content("ping"),\
         exchange='amq.direct')
print 'done'

print 'Receiving message'
t = ch.basic_consume(queue="test1", no_ack=True)
q = client.queue(t.consumer_tag)
msg = q.get(timeout=1)
print 'Got message:', msg.content.body

#-----------------------------------------------



If anybody is interested, when this code runs against 0.8 xml spec from 
qpid trunk, here is what I get in rabbit.log:

=INFO REPORT==== 7-Sep-2007::13:45:31 ===
accepted TCP connection on 0.0.0.0:5672 from 127.0.0.1:2586

=WARNING REPORT==== 7-Sep-2007::13:45:31 ===
Attempt by client to use invalid ticket 0

=WARNING REPORT==== 7-Sep-2007::13:45:31 ===
Lax ticket check mode: fabricating full ticket number 0

=ERROR REPORT==== 7-Sep-2007::13:45:31 ===
Frame error: 'basic.consume', <<0,0,5,116,101,115,116,49,0,2,0,0,0,0>>

=INFO REPORT==== 7-Sep-2007::13:45:31 ===
Sending exception: Channel 1, Reason {amqp,frame_error,'basic.consume'}

=INFO REPORT==== 7-Sep-2007::13:45:31 ===
closing TCP connection from 127.0.0.1:2586

This is on debian etch, original 1.1.1-1 rabbitmq-server deb.
python 2.4.4


- Dmitriy






Matthias Radestock wrote:
> Edwin,
> 
> Edwin Grubbs wrote:
>> Has anyone been able to get a python client working with rabbitmq? I
>> have been trying to use qpid, but I haven't had much luck.
> 
> We are running qpid's python-based test suite against RabbitMQ as part 
> of our conformance and interop testing. See
> http://www.rabbitmq.com/interoperability.html#qpid-python-tests
> 
> That definitely works for us.
> 
> What exactly did you try?
> 
> 
> Matthias.
> 
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
> 




More information about the rabbitmq-discuss mailing list