diff options
author | 2018-05-25 14:21:10 +0200 | |
---|---|---|
committer | 2018-05-25 14:21:10 +0200 | |
commit | 85dbc20a80a2b4c233708be1460da7909e205388 (patch) | |
tree | 36d98fca1d490ffe4af0b07defe979389fbe5390 /rmq/publisher.py | |
parent | generate new queue based on session id to lock user to their own event chain (diff) |
lint
Diffstat (limited to 'rmq/publisher.py')
-rw-r--r-- | rmq/publisher.py | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/rmq/publisher.py b/rmq/publisher.py index 4ba9db9..1a9a5cf 100644 --- a/rmq/publisher.py +++ b/rmq/publisher.py @@ -1,6 +1,16 @@ import pika -def publish(message, username='guest', password='guest', host='localhost', port=5672, queue='', routingkey='', exchange='', exchange_type=''): + +def publish(message, + username='guest', + password='guest', + host='localhost', + port=5672, + queue='', + routingkey='', + exchange='', + exchange_type=''): + credentials = pika.PlainCredentials(username, password) connection = pika.BlockingConnection(pika.ConnectionParameters(host, port, '/', credentials)) properties = pika.BasicProperties(content_type='text/plain', delivery_mode=1) @@ -11,10 +21,10 @@ def publish(message, username='guest', password='guest', host='localhost', port= channel.queue_bind(exchange=exchange, queue=queue, routing_key=routingkey) result = channel.basic_publish( - exchange=exchange, - routing_key=routingkey, - body=message, - properties=properties + exchange=exchange, + routing_key=routingkey, + body=message, + properties=properties ) if result: @@ -23,4 +33,3 @@ def publish(message, username='guest', password='guest', host='localhost', port= print("not delivered") connection.close() - |