¡Esta es una revisión vieja del documento!
$ echo "deb http://www.rabbitmq.com/debian/ testing main" >> /etc/apt/sources.list $ wget http://www.rabbitmq.com/rabbitmq-signing-key-public.asc $ sudo apt-key add rabbitmq-signing-key-public.asc $ sudo apt-get install rabbitmq-server
$ sudo service rabbitmq-server status
Where status can be start, stop, restart…
$ sudo rabbitmqctl list_queues
$ sudo rabbitmqctl list_queues name messages_ready messages_unacknowledged
#!/usr/bin/env python # -*- coding: utf-8 -*- import pika connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost')) channel = connection.channel() channel.queue_declare(queue='hello') for i in xrange(100): msg = 'Hello World! - ' + str(i) channel.basic_publish(exchange='', routing_key='hello', body=msg) print " [x] Sent", msg connection.close()
#!/usr/bin/env python # -*- coding: utf-8 -*- import pika def callback(ch, method, properties, body): print " [x] Received %r" % (body,) connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost')) channel = connection.channel() channel.queue_declare(queue='hello') print ' [*] Waiting for messages. To exit press CTRL+C' channel.basic_consume(callback, queue='hello', no_ack=True) channel.start_consuming()
no_ack means no acknowledgement messages.prefetch_count=1 into the worker channel.no_ack parameter.