better load balancing
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Torma Kristóf 2020-10-24 00:50:55 +02:00
parent 735888e56f
commit b20fbea277
1 changed files with 5 additions and 2 deletions

View File

@ -27,6 +27,7 @@ def message_callback(channel, method, properties, body):
routing_key='classification-result',
body=json.dumps(results).encode("utf-8")
)
channel.basic_ack(delivery_tag = method.delivery_tag)
def main():
@ -57,12 +58,14 @@ def main():
channel = connection.channel()
channel.exchange_declare(exchange=os.environ['PIKA_INPUT_EXCHANGE'], exchange_type='direct')
queue_declare_result = channel.queue_declare(queue='', exclusive=True)
queue_declare_result = channel.queue_declare(queue='cnnqueue', exclusive=True)
queue_name = queue_declare_result.method.queue
channel.queue_bind(exchange=os.environ['PIKA_INPUT_EXCHANGE'],routing_key='feature', queue=queue_name)
channel.basic_consume(queue=queue_name, on_message_callback=message_callback, auto_ack=True)
channel.basic_qos(prefetch_count=1)
channel.basic_consume(queue=queue_name, on_message_callback=message_callback, auto_ack=False)
logging.info("Connection complete! Listening to messages...")
try: