Skip to content
Snippets Groups Projects
Commit c10c702e authored by Mitchell Moore's avatar Mitchell Moore
Browse files

Duplicate producer code for in app testing

parent d0d0526b
No related branches found
No related tags found
1 merge request!35Version 1b openstack rabbitmq
......@@ -51,22 +51,25 @@ def handle_my_custom_event(json, methods=['GET', 'POST']):
def ingest_data(json, methods=['GET', 'POST']):
print (time.strftime("%m-%d-%Y_%H:%M:%S") + '\tQueue request received: ' + str(json))
# Begin RabbitMQ process.
connection = pika.BlockingConnection(
pika.ConnectionParameters(host='localhost'))
# Begin RabbitMQ process.
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')
message = "Hey there" # todo: account info goes here
node = sys.argv[1] if len(sys.argv) > 1 else 'info'
message = ' '.join(sys.argv[2:]) or 'Hello World!'
channel.basic_publish(
exchange='direct_logs', routing_key="ohpc", body=message)
print(" [x] Sent %r:%r" % ("ohpc", message))
exchange='direct_logs', routing_key=node, body=message)
print(" [x] Sent %r:%r" % (node, message))
channel.basic_publish(
exchange='direct_logs', routing_key="ood", body=message)
print(" [x] Sent %r:%r" % ("ood", message))
connection.close()
# Todo: Make the remaining portion of this method in a RabbitMQ consumer
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment