Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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:

  1. 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.)
  2. 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?

share|improve this question
    
"Best practice" recommendations are always written to an idealized, average setting. Specific knowledge about parameters of the actual situation is almost always more decisive. You have already given the pro/con considerations, and started to consider the specifics (i.e. that size of entire email is still small enough to not matter). This means that you are almost certainly better off following your situation-specific information rather than any general "best practice". –  Kilian Foth May 23 '13 at 6:13
    
But best practice generally stem from people with experience in these situations. I doubt I'm the first person to come across this problem and was hoping someone had already dealt with this exact situation and could shed some light on their decision etc. –  Omar May 23 '13 at 13:42

1 Answer 1

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.