redo rabbit publisher
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-07-03 14:29:00 +02:00
parent d76b0b8a9e
commit 23197e0ba8
4 changed files with 111 additions and 8 deletions

View File

@ -10,6 +10,7 @@ from db import db
from models import SampleMetadata
from schemas import SampleSchema, SampleMetadataSchema
from config import *
from rabbit_broker_instance import mq
"""
Flask Restful endpoints
@ -76,14 +77,7 @@ class SampleResource(Resource):
soundfile,
soundfile.content_type,
{'Content-Length': soundfile.content_length})}).raise_for_status()
credentials = pika.PlainCredentials(RABBITMQ_USERNAME, RABBITMQ_PASSWORD)
rabbitmq = pika.BlockingConnection(pika.ConnectionParameters(host=RABBITMQ_HOST, credentials=credentials))
rabbitmq_channel = rabbitmq.channel()
rabbitmq_channel.exchange_declare(exchange=RABBITMQ_EXCHANGE, exchange_type='fanout')
rabbitmq_channel.basic_publish(
exchange=RABBITMQ_EXCHANGE,
routing_key='feature',
body=json.dumps({'tag': generated_tag}).encode('utf-8'))
mq.send(json.dumps({'tag': generated_tag}))
except Exception as e:
LOGGER.exception(e)
db.session.rollback()