Skip to content
Snippets Groups Projects
test_producer.py 575 B
Newer Older
Mitchell Moore's avatar
Mitchell Moore committed
import pika
import sys

# Begin RabbitMQ process.
connection = pika.BlockingConnection(
    pika.ConnectionParameters(host='localhost'))
channel = connection.channel()

channel.exchange_declare(exchange='direct_logs', exchange_type='direct')

message = "Hey there"  # todo: account info goes here

channel.basic_publish(
    exchange='direct_logs', routing_key="ohpc", body=message)
print(" [x] Sent %r:%r" % ("ohpc", message))

channel.basic_publish(
    exchange='direct_logs', routing_key="ood", body=message)
print(" [x] Sent %r:%r" % ("ood", message))
connection.close()