diff --git a/antivirus_service/consumer.py b/antivirus_service/consumer.py index e162a49..659b079 100644 --- a/antivirus_service/consumer.py +++ b/antivirus_service/consumer.py @@ -11,6 +11,7 @@ def __init__(self, settings, handler): self.handler = handler self.amqp_config = settings.config[settings.env]['amqp'] self.amqp_url = self.amqp_config['url'] + self.exchange = self.amqp_config['exchange'] self.amqp_queue = None def _callback(self, ch, method, properties, body): @@ -36,7 +37,8 @@ def run(self): channel = self.connection.channel() channel.queue_declare(self.amqp_queue) - channel.basic_consume(self.amqp_queue,self._callback) + channel.queue_bind(self.amqp_queue, self.exchange) + channel.basic_consume(self.amqp_queue, self._callback) channel.start_consuming() def stop(self): diff --git a/antivirus_service/handler.py b/antivirus_service/handler.py index 1f44497..b4b3d4f 100644 --- a/antivirus_service/handler.py +++ b/antivirus_service/handler.py @@ -69,7 +69,7 @@ def scan(self, download_uri, access_token): def callback(self, callback_uri, access_token, scan_result, signature): logging.info('Start callback') - headers = {} + headers = {'Content-type': 'application/json'} if access_token: headers['Authorization'] = 'Bearer %s' % access_token diff --git a/antivirus_service/service.py b/antivirus_service/service.py index 7e61912..7c039ff 100644 --- a/antivirus_service/service.py +++ b/antivirus_service/service.py @@ -38,6 +38,7 @@ def __init__(self, env, debug): with env.prefixed(param.upper() + "_"): self.config[self.env][param] = {} self.config[self.env][param]['url'] = env("URL", "amqp://rabbitmq/antivirus") + self.config[self.env][param]['exchange'] = env("EXCHANGE", "antivirus") with env.prefixed("SCAN_FILE_"): self.config[self.env][param]['scan_file'] = {} self.config[self.env][param]['scan_file']['queue'] = env("QUEUE", "scan_file") diff --git a/antivirus_service/webserver.py b/antivirus_service/webserver.py index 4b37071..74d054a 100644 --- a/antivirus_service/webserver.py +++ b/antivirus_service/webserver.py @@ -133,7 +133,7 @@ def send(self, body, routing_key): params = pika.URLParameters(self.amqp_config['url']) with pika.BlockingConnection(params) as con: with con.channel() as channel: - channel.basic_publish(body=body, exchange='', routing_key=routing_key) + channel.basic_publish(body=body, exchange=self.amqp_config['exchange'], routing_key=routing_key) @auth_required async def handle_version(self, request):