Skip to content

Commit

Permalink
Merge pull request #355 from weni-ai/feature/template-type-handle-exc…
Browse files Browse the repository at this point in the history
…eptions

Handle exceptions to sentry and dlx in TemplateTypeConsumer
  • Loading branch information
Sandro-Meireles authored Sep 28, 2023
2 parents ed3fa0b + 910c0a8 commit baf3222
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions marketplace/projects/consumers/template_type_consumer.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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}")

0 comments on commit baf3222

Please sign in to comment.