diff --git a/base_consumer.py b/base_consumer.py index 2e9e08ebfcd30b2e252411126a650bfde01df0e4..ebfe9dd0a65c9b4c9cdcf9b21cb1d15bf7dd2d9a 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 32700be88e84429a35dd0efeb1d8f21425e50d6a..ce69cf63498e5dae3ee11404c433c20ad7553a59 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')