[rabbitmq-discuss] pika error - need a help

Marek Majkowski majek04 at gmail.com
Fri Sep 9 17:26:48 BST 2011


On Wed, Sep 7, 2011 at 06:39, Sergey Almazov <sergey.almazoff at gmail.com> wrote:
> #!/usr/bin/env python
> import pika
> import sys

This code doesn't look correct. Which pika version are you using?

Here is similar code (but working) using blocking connection. Maybe it
will print you more meaningful error message. You also may be able to
see something useful in  rabbitmq logs.

Cheers,
   Marek


#!/usr/bin/env python
import pika
import sys
import time

connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
channel = connection.channel()

channel.exchange_declare(exchange='cmd', type='topic')

cmd_data_queue = channel.queue_declare(exclusive=True).method.queue

channel.queue_bind(exchange='cmd', queue=cmd_data_queue, routing_key='cmd.*')

def callback(ch, method, properties, body):
    print " [x] %r:%r" % (method.routing_key, body,)


channel.basic_consume(callback, queue=cmd_data_queue, no_ack=True)
channel.start_consuming()


More information about the rabbitmq-discuss mailing list