This commit is contained in:
@ -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()
|
||||
|
Reference in New Issue
Block a user