Newer
Older
pika.ConnectionParameters(host='localhost')) # connecting to a broker on the local machine
channel.exchange_declare(exchange='direct_logs', exchange_type='direct') # create exchange to pass messages
result = channel.queue_declare(queue='', exclusive=True)
queue_name = result.method.queue # creates a random name for the newly generated queue
exchange='direct_logs', queue=queue_name, routing_key="ood") # combine exchange, queue, and define routing name
print(' [*] Waiting for logs. To exit press CTRL+C')
def callback(ch, method, properties, body):
message = "ood sent this"
channel.basic_publish(
exchange='direct_logs', routing_key="manager", body=message)
# Todo: Make message manager more functional
queue=queue_name, on_message_callback=callback, auto_ack=True) # ingest messages, and assume delivered via auto_ack
channel.start_consuming() # initiate message ingenstion