4
votes

we just moved some of our workloads to azure for which i am currently managing, i read a little about service bus and was wondering if i can use it to queue emails

applications hosted in azure though the use of a custom library will deliver their emails to a service bus queue where one or more worker processes will pick messages off the queue and send then though a mail relay service.

this will free my developers from the details of which mail relay service i am using at anytime and i can also perform further processing of the messages before sending without the developers changing their code.

my questions are, is this possible, if it is, is it advisable and is there anything i need to watch out for when implementing such a solution. any pointers on how to do it will also be appreciated

3
Yes it is possible, what have you tried till now? It is just a queuing system to handle workloads.Peter
i have not given it a try, just getting used to azure infrastructure, i just want to know if its worth the effort involved or its a dead end. i also want to know if its a good ideaaraoko

3 Answers

6
votes

Yes, it is a reasonable solution to add messages to an Azure Service Bus Queue that are later retrieved by an application that goes and send emails based on the details in the queued messages. This is a good way to decouple your various applications using a Microservices approach to providing an email sending service to be used either within the different pieces of a single app, or even across many apps within the organization.

One thing to watch out for is that the Message size in the Azure Service Bus Queue does have a maximum size limit. Depending on the length of the content being sent in the emails, you will need to store the details of the message somewhere, perhaps a database or Azure Table Storage. Then the message in the Queue would contain an identifier, such as a GUID, that could be used to look up the message details later when the receiving application processes it to send the email out. No matter the size of the massage in the queue, emails can get quite long, so using this approach is probably the best option for you so you wont have issues later with the implementation.

1
votes

Without knowing anything about your system, requirements, on need in messaging vs queuing, I'm going to say that following.

  • If your application has a need in messaging, then go ahead and use Azure Service Bus for queuing emails as well.
  • In case the answer is "no", use something that is solely queuing: Azure Storage Queues.
0
votes

It's possible and it's good choice. Most of email services uses queue in their systems.

You can use priority property of queue. Transactional Mails>Notification Mails>Marketing Mails, you can give high to low priority. Because queue works fifo and transactional mails shouldn't wait for marketing mails.

You can use Labels distinguish messages, before implemantation.

If you can't send an email after for some tries(default 10 for Azure). You should move it to dead queue azure service bus does this for you. But then you should consume deadqueue for handling this emails.