Commit 5005f9ab authored by Francesco Pace's avatar Francesco Pace
Browse files

Add exchange parameter for RabbitMQ protocol


Signed-off-by: default avatarFrancesco Pace <pace.francesco.g@gmail.com>
parent 9d325b0d
......@@ -210,3 +210,5 @@ def _channel_check(data):
if data['protocol'] is 'rabbitmq':
if 'queue' not in data:
raise InvalidApplicationDescription(msg="Missing required key: queue")
if 'exchange' not in data:
raise InvalidApplicationDescription(msg="Missing required key: exchange")
......@@ -32,9 +32,9 @@ class RabbitMQ:
connection = pika.BlockingConnection(pika.ConnectionParameters(self.host, credentials=credentials))
self.channel = connection.channel()
def send_message(self, queue, message):
log.debug("Sending message to RabbitMQ. Message -> {} // Queue -> {}".format(message, queue))
self.channel.basic_publish(exchange='',
def send_message(self, exchange, queue, message):
log.debug("Sending message to RabbitMQ. Message -> {} // Exchange -> {} // Queue -> {}".format(message, exchange, queue))
self.channel.basic_publish(exchange=exchange,
routing_key=queue,
body=message)
......
......@@ -29,5 +29,5 @@ class Crystal:
log.debug("Transmitting policy to Crystal via RabbitMQ")
rmq = RabbitMQ(self.channel['username'], self.channel['password'], self.channel['host'])
rmq.open_connection()
rmq.send_message(self.channel['queue'], message)
rmq.send_message(self.channel['exchange'], self.channel['queue'], message)
rmq.close_connection()
Markdown is supported
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