def connect(self):
     return Connection.instance(
         host=current_app.config['RABBIT_HOST'],
         port=current_app.config['RABBIT_PORT'],
         vhost=current_app.config['RABBIT_VHOST'],
         user=current_app.config['RABBIT_USER'],
         password=current_app.config['RABBIT_PASSWORD'],
         clean_creds=current_app.config['RABBIT_CLEAN_CREDS'],
         heartbeat_interval=current_app.config['RABBIT_HEARTBEAT_INTERVAL'],
         ca_certs=current_app.config['RABBIT_CA_CERTS'],
         cert_reqs=current_app.config['RABBIT_CERT_REQS'],
         certfile=current_app.config['RABBIT_CERTFILE'],
         keyfile=current_app.config['RABBIT_KEYFILE'],
         ssl_enable=current_app.config['RABBIT_SSL_ENABLE'],
         ssl_version=current_app.config['RABBIT_SSL_VERSION']
     )
Example #2
0
#!/usr/bin/env python

from rabbitplay import Producer
from rabbitplay import RabbitConnection as Connection
import argparse


parser = argparse.ArgumentParser()
parser.add_argument("queue", nargs="?", default="hello_world_queue")
parser.add_argument("message", default="Hello World!")
args = parser.parse_args()

with Connection.instance(user="******", password="******", vhost="vhost") as conn:

    print "queue:   {}\nmessage: {}".format(args.queue, args.message)
    producer1 = Producer(conn)
    producer1.publish(args.queue, args.message)
Example #3
0
#!/usr/bin/env python

from rabbitplay import Producer
from rabbitplay import RabbitConnection as Connection
from time import sleep

with Connection.instance(user='******', password='******',
                         vhost='vhost') as conn:

    producer1 = Producer(conn)
    producer1.publish('queue1', 'msg1')
    producer1.publish('queue2', 'msg1')
    producer1.publish('queue2', 'msg2')

    sleep(3)

    producer2 = Producer(conn)
    producer2.publish('queue3', 'msg1')
    producer2.publish('queue4', 'msg1')