diff --git a/marketplace/projects/consumers/template_type_consumer.py b/marketplace/projects/consumers/template_type_consumer.py index 5fc8f48e..56331f18 100644 --- a/marketplace/projects/consumers/template_type_consumer.py +++ b/marketplace/projects/consumers/template_type_consumer.py @@ -1,4 +1,5 @@ import amqp +from sentry_sdk import capture_exception from marketplace.event_driven.parsers import JSONParser from marketplace.event_driven.consumers import EDAConsumer @@ -7,10 +8,16 @@ class TemplateTypeConsumer(EDAConsumer): # pragma: no cover def consume(self, message: amqp.Message): - body = JSONParser.parse(message.body) + print(f"[TemplateTypeConsumer] - Consuming a message. Body: {message.body}") - print(f"[TemplateTypeConsumer] - Consuming a message. Body: {body}") + try: + body = JSONParser.parse(message.body) - create_template_type(uuid=body.get("uuid"), project_uuid=body.get("project_uuid"), name=body.get("name")) + create_template_type(uuid=body.get("uuid"), project_uuid=body.get("project_uuid"), name=body.get("name")) - message.channel.basic_ack(message.delivery_tag) + message.channel.basic_ack(message.delivery_tag) + + except Exception as exception: + capture_exception(exception) + message.channel.basic_reject(message.delivery_tag, requeue=False) + print(f"[ProjectConsumer] - Message rejected by: {exception}")