I have a web application that sends out transactional (triggered) emails to users. We’ve setup a message queue for the web application to write to when it needs to send out an email (best practices reasons etc.).
The question I’m struggling with is when to have the email template parsed into text:
-
Parse the template and place the entire email body into the queue
- Pro: can keep the business logic and template close by
- Con: more data over the wire to the queue (email body vs email type/ids etc.)
-
Parse the template as part of the queue processing (before it’s sent to the transactional email service)
- Pro: less data over the wire to the queue, less processing on the messaging logic
- Con: queue processor needs to have business logic
I like option #1 because I don’t see data over wire ever getting too big and keeping the email logic in a central location makes more logical sense from a development standpoint.
Is there a best practice in this situation?
2
I agree with your reasons to choose option #1. If the e-mails you send won’t clog up your Internet connection, why should they clog up the network connection between your web application and your queue processor?
There is always a trade-off between code maintainability and performance. However, since you state yourself that performance problems with option #1 are possible but unlikely, I would not sacrifice code maintainability for an unlikely performance problem.