From a3fc9d3009476ef7c5560e43af14bcbef94bfafa Mon Sep 17 00:00:00 2001 From: Mitchell Moore <mmoo97@uab.edu> Date: Mon, 10 Feb 2020 15:05:08 -0600 Subject: [PATCH] Fix connection parameters for cluster --- base_consumer.py | 12 ++++++++---- test_producer.py | 10 ++++++++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/base_consumer.py b/base_consumer.py index 2e9e08e..ebfe9dd 100644 --- a/base_consumer.py +++ b/base_consumer.py @@ -1,9 +1,14 @@ #!/usr/bin/env python -import pika # python client +import pika # python client import sys -connection = pika.BlockingConnection( - pika.ConnectionParameters(host='localhost')) # connecting to a broker on the local machine +credentials = pika.PlainCredentials('reggie', 'reggie') +parameters = pika.ConnectionParameters('ood', + 5672, + '/', + credentials) +connection = pika.BlockingConnection(parameters) + channel = connection.channel() channel.exchange_declare(exchange='direct_logs', exchange_type='direct') # create exchange to pass messages @@ -28,7 +33,6 @@ def callback(ch, method, properties, body): print('[%r] User creation task is done.' % method.routing_key) - channel.basic_consume( queue=queue_name, on_message_callback=callback, auto_ack=True) # ingest messages, and assume delivered via auto_ack diff --git a/test_producer.py b/test_producer.py index 32700be..ce69cf6 100644 --- a/test_producer.py +++ b/test_producer.py @@ -2,8 +2,14 @@ import pika import sys # Begin RabbitMQ process. -connection = pika.BlockingConnection( - pika.ConnectionParameters(host='localhost')) +credentials = pika.PlainCredentials('reggie', 'reggie') +parameters = pika.ConnectionParameters('ood', + 5672, + '/', + credentials) + +connection = pika.BlockingConnection(parameters) + channel = connection.channel() channel.exchange_declare(exchange='direct_logs', exchange_type='direct') -- GitLab