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

Add comments and display routing to manager

parent ac267069
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python
import pika
import pika # python client
connection = pika.BlockingConnection(
pika.ConnectionParameters(host='localhost'))
pika.ConnectionParameters(host='localhost')) # connecting to a broker on the local machine
channel = connection.channel()
channel.exchange_declare(exchange='direct_logs', exchange_type='direct')
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
queue_name = result.method.queue # creates a random name for the newly generated queue
channel.queue_bind(
exchange='direct_logs', queue=queue_name, routing_key="manager")
exchange='direct_logs', queue=queue_name, routing_key="manager") # combine exchange, queue, and define routing name
print(' [*] Waiting for logs. To exit press CTRL+C')
......@@ -22,6 +22,6 @@ def callback(ch, method, properties, body):
channel.basic_consume(
queue=queue_name, on_message_callback=callback, auto_ack=True)
queue=queue_name, on_message_callback=callback, auto_ack=True) # ingest messages, and assume delivered via auto_ack
channel.start_consuming()
\ No newline at end of file
channel.start_consuming() # initiate message ingenstion
#!/usr/bin/env python
import pika
import pika # python client
connection = pika.BlockingConnection(
pika.ConnectionParameters(host='localhost'))
pika.ConnectionParameters(host='localhost')) # connecting to a broker on the local machine
channel = connection.channel()
channel.exchange_declare(exchange='direct_logs', exchange_type='direct')
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
queue_name = result.method.queue # creates a random name for the newly generated queue
channel.queue_bind(
exchange='direct_logs', queue=queue_name, routing_key="ohpc")
exchange='direct_logs', queue=queue_name, routing_key="ohpc") # combine exchange, queue, and define routing name
print(' [*] Waiting for logs. To exit press CTRL+C')
def callback(ch, method, properties, body):
print(" [x] %r:%r" % (method.routing_key, body))
# Todo: Make message manager more functional
channel.basic_consume(
queue=queue_name, on_message_callback=callback, auto_ack=True)
queue=queue_name, on_message_callback=callback, auto_ack=True) # ingest messages, and assume delivered via auto_ack
channel.start_consuming()
\ No newline at end of file
channel.start_consuming() # initiate message ingenstion
#!/usr/bin/env python
import pika
import pika # python client
connection = pika.BlockingConnection(
pika.ConnectionParameters(host='localhost'))
pika.ConnectionParameters(host='localhost')) # connecting to a broker on the local machine
channel = connection.channel()
channel.exchange_declare(exchange='direct_logs', exchange_type='direct')
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
queue_name = result.method.queue # creates a random name for the newly generated queue
channel.queue_bind(
exchange='direct_logs', queue=queue_name, routing_key="ood")
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)
print(" [x] %r:%r" % (method.routing_key, body))
# Todo: Make message manager more functional
channel.basic_consume(
queue=queue_name, on_message_callback=callback, auto_ack=True)
queue=queue_name, on_message_callback=callback, auto_ack=True) # ingest messages, and assume delivered via auto_ack
channel.start_consuming()
\ No newline at end of file
channel.start_consuming() # initiate message ingenstion
......@@ -17,4 +17,5 @@ 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()
\ No newline at end of file
connection.close()
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