diff options
| author | 2018-05-26 12:54:49 +0200 | |
|---|---|---|
| committer | 2018-05-26 12:54:49 +0200 | |
| commit | ea2141dc6fd7284e6f9fa04ee638460286e3b09c (patch) | |
| tree | 218d332be80bd2f4e177b0d9e4725dd27dec2034 /rmq/publisher.py | |
| parent | lint (diff) | |
simplify threads and use local thread variables to manage user websocket connections
Diffstat (limited to 'rmq/publisher.py')
| -rw-r--r-- | rmq/publisher.py | 35 | 
1 files changed, 0 insertions, 35 deletions
| diff --git a/rmq/publisher.py b/rmq/publisher.py deleted file mode 100644 index 1a9a5cf..0000000 --- a/rmq/publisher.py +++ /dev/null @@ -1,35 +0,0 @@ -import pika - - -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) - -    channel = connection.channel() -    channel.queue_declare(queue=queue, durable=False) -    channel.exchange_declare(exchange=exchange, exchange_type=exchange_type) -    channel.queue_bind(exchange=exchange, queue=queue, routing_key=routingkey) - -    result = channel.basic_publish( -        exchange=exchange, -        routing_key=routingkey, -        body=message, -        properties=properties -    ) - -    if result: -        print(f"Connecting to host: {host} port: {port} exchange: {exchange} queue: {queue}", flush=True) -    else: -        print("not delivered") - -    connection.close() | 
