diff --git a/scripts/test-rabbitmq.connection.py b/scripts/test-rabbitmq.connection.py index 59d08373..c1cb77bd 100644 --- a/scripts/test-rabbitmq.connection.py +++ b/scripts/test-rabbitmq.connection.py @@ -2,23 +2,27 @@ import pika import logging +import os + +connection_string = os.getenv( + "RABBITMQ_URL", default="amqp://guest:guest@localhost:5672" +) + # create our logger logger = logging.getLogger(__name__) -# make sure have the logger set to level to +# make sure have the logger set to level to # accept the logging statements logger.setLevel(logging.DEBUG) -# create a handler for our logs, so we can see them +# create a handler for our logs, so we can see them console = logging.StreamHandler() # add the handler, so logs are shared as stream to STDOUT logger.addHandler(console) -connection = pika.BlockingConnection( - pika.URLParameters("amqp://guest:guest@localhost:5672") -) +connection = pika.BlockingConnection(pika.URLParameters(connection_string)) -# we need a channel to sent things to +# we need a channel to sent things to channel = connection.channel() channel.queue_declare(queue="hello") @@ -26,3 +30,5 @@ logger.info(" [x] Sent 'Hello World!'") connection.close() + +print(" [x] Sent 'Hello World!'")