Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idempotency Concern of the Mail Sender Function #16

Open
NullPointer4096 opened this issue Apr 16, 2023 · 1 comment
Open

Idempotency Concern of the Mail Sender Function #16

NullPointer4096 opened this issue Apr 16, 2023 · 1 comment

Comments

@NullPointer4096
Copy link

Description:

I would like to kindly bring attention to a potential issue in the Mail Sender function, which is invoked when a ServiceBus message arrives at the "reservation" queue. This function calls the SendGrid API to send a car reservation confirmation to a customer's email. However, the email sending is not idempotent; Suppose the ServiceBus-triggered function crashes after successfully sending an email (but before acknowledging the ServiceBus that the function has finished), when the function is retried, another email will be sent by SendGrid. In other words, ServiceBus-triggered function has at-least-once execution guarantee, so in this function, email sending could happen multiple times.

Suggested Fix:

Although there's no serious harm in sending two almost identical emails, this duplicate sending due to untimely retries can be prevented. Specifically, SendGrid provides the Email Activity Feed API that one can use to query whether the email has been sent (in a previous execution) before actually sending the email. Suppose the query finds no email has been sent, then go ahead and send the email. If querying the SendGrid service finds the email has been sent, end the execution without sending the email again.

Thank you for considering this issue. I hope this suggestion could help improve the idempotency and user experience of the Mail Sender function. Please feel free to reach out if you have any questions or concerns.

@Daniel-Krzyczkowski
Copy link
Owner

Hi @NullPointer4096,

Thank you so much for the suggestion. This is really helpful and I agree that even if this is not a big problem it would be nice to enhance the mail sender function functionality.
If you have some time, would you be able to provide some PR with changes? Even if not, this is great suggestion for others to know, thank you once again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants