[rabbitmq-discuss] python hello world

Lynton Grice lynton.grice at netweaverguru.com
Mon May 5 07:51:02 BST 2008


Hi Mark,

 

Here is the script I got going the other day ;-)

 

import sys

 

sys.path = sys.path + ['D:\Python24\Lib\site-packages\python-qpid']

 

import qpid

from qpid.client import Client

from qpid.content import Content

 

client = Client("localhost", 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="testq", exclusive=True)

 

ch.queue_bind(queue="testq", exchange="amq.direct", routing_key="test") 

 

print 'Sending message "ping"...  ', 

ch.basic_publish(routing_key="test",
content=Content("ping"),exchange='amq.direct') 

print 'done' 

 

print 'Receiving message' 

t = ch.basic_consume(queue="testq", no_ack=True) 

q = client.queue(t.consumer_tag) 

msg = q.get(timeout=1) 

print 'Got message:', msg.content.body 

q.close()

client.close()

 

Regards

 

Lynton

  _____  

From: rabbitmq-discuss-bounces at lists.rabbitmq.com
[mailto:rabbitmq-discuss-bounces at lists.rabbitmq.com] On Behalf Of mark
Sent: 04 May 2008 11:44 PM
To: rabbitmq-discuss at lists.rabbitmq.com
Subject: [rabbitmq-discuss] python hello world

 

Hi
I have rabbitmq-server 1.3 installed and running, and python qpid installed.
Can you give a very basic example how to set and get from a queue? How many
queues does rabbitmq-start?

thanks

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20080505/6c7c2328/attachment.htm 


More information about the rabbitmq-discuss mailing list