Skip to content

Instantly share code, notes, and snippets.

@lukebakken
Last active October 4, 2017 22:33
Show Gist options
  • Save lukebakken/1aefe2716f8bfc3d2ead59a54ad44d95 to your computer and use it in GitHub Desktop.
Save lukebakken/1aefe2716f8bfc3d2ead59a54ad44d95 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import pika
import sys
def callback(ch, method, properties, body):
pass
# print(" [x] Received %r" % body)
queue_name = sys.argv[1]
cp = pika.ConnectionParameters('shostakovich')
connection = pika.BlockingConnection(cp)
channel = connection.channel()
# channel.basic_qos(prefetch_count=20480)
# for method_frame, properties, body in channel.consume(queue_name):
# channel.basic_ack(method_frame.delivery_tag)
channel.basic_consume(callback, queue=queue_name, no_ack=True)
print(' [*] Waiting for messages. To exit press CTRL+C')
channel.start_consuming()
#!/usr/bin/env python
import pika
import sys
queue_name = sys.argv[1]
cp = pika.ConnectionParameters('shostakovich')
connection = pika.BlockingConnection(cp)
channel = connection.channel()
channel.queue_declare(queue=queue_name)
while True:
channel.basic_publish(exchange='', routing_key=queue_name, body='Hello!')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment