Commit 2487e583 authored by Cloud User's avatar Cloud User
Browse files

Quick update with consumers

Still need to add user into rabbimq server:

sudo rabbitmqctl add_user reggie
sudo rabbitmqctl set_permissions reggie ".*" ".*" ".*"
parent 4646d2eb
......@@ -18,6 +18,7 @@ print(' [*] Waiting for logs. To exit press CTRL+C')
def callback(ch, method, properties, body):
print(" [x] %r:%r" % (method.routing_key, body))
print('[manager] User creation task is done.')
# Todo: Make message manager more functional
......
......@@ -19,6 +19,10 @@ 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
print('[ohpc] User has been created')
channel.basic_publish(
exchange='direct_logs', routing_key="ood", body='{uid:1002,gid:1002}')
print(" [x] Sent %r:%r" % ("ood", '{uid:1002, gid:1002}'))
channel.basic_consume(
......
#!/usr/bin/env python
import pika # python client
connection = pika.BlockingConnection(
pika.ConnectionParameters(host='localhost')) # connecting to a broker on the local machine
credentials = pika.PlainCredentials('reggie', 'reggie')
parameters = pika.ConnectionParameters('ohpc',
5672,
'/',
credentials)
connection = pika.BlockingConnection(parameters)
channel = connection.channel()
channel.exchange_declare(exchange='direct_logs', exchange_type='direct') # create exchange to pass messages
......@@ -17,11 +21,12 @@ 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
print('[ood] User has been created')
channel.basic_publish(
exchange='direct_logs', routing_key="manager", body='{status:"done"}')
print(" [x] Sent %r:%r" % ("manager", '{status:done}'))
channel.basic_consume(
......
......@@ -8,14 +8,10 @@ channel = connection.channel()
channel.exchange_declare(exchange='direct_logs', exchange_type='direct')
message = "Hey there" # todo: account info goes here
message = "Hey need an account here" # 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()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment