From 5b727cb51c86d7a954c8388c0957f35e4595e33f Mon Sep 17 00:00:00 2001 From: YuehuCao Date: Fri, 15 Aug 2025 00:23:22 +0800 Subject: [PATCH] fix(email sending): guidance for use of exchange --- apps/notification/backend/infra/rabbitmq/async_client.py | 3 ++- apps/notification/tests/integration_tests/README.md | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/apps/notification/backend/infra/rabbitmq/async_client.py b/apps/notification/backend/infra/rabbitmq/async_client.py index 61456b7..70b9143 100644 --- a/apps/notification/backend/infra/rabbitmq/async_client.py +++ b/apps/notification/backend/infra/rabbitmq/async_client.py @@ -8,7 +8,8 @@ import aio_pika class AsyncMQClient: # TODO: change to freeleaps.notification.exchange.{} # in local test, we use freeleaps.notification.exchange.local.{} to avoid repeating sending emails - exchange_name_format = "freeleaps.notification.exchange.local.{}" + #exchange_name_format = "freeleaps.notification.exchange.local.{}" + exchange_name_format = "freeleaps.notification.exchange.{}" exchange_type = "direct" def __init__(self, channel_name: str) -> None: diff --git a/apps/notification/tests/integration_tests/README.md b/apps/notification/tests/integration_tests/README.md index 77afe94..4c99f13 100644 --- a/apps/notification/tests/integration_tests/README.md +++ b/apps/notification/tests/integration_tests/README.md @@ -33,4 +33,11 @@ tenant_notification.py ```shell # run the command python test_tenant_notification_real.py -``` \ No newline at end of file +``` +After running the commands, email will be sent + +## Q & A +### Q: Why is the email sent twice? +### Q: Why do I recieve 2 identical emails at the same time + +### A: in infra/rabbitmq/async_client.py, use exchange_name_format = "freeleaps.notification.exchange.local.{}" for local environment, while exchange_name_format = "freeleaps.notification.exchange.{}" for alpha environment. \ No newline at end of file