Re:Using a Message Queue vs Background Processing.
by mnbbrown on Tuesday July 24, 2012 @06:45AM
(#4285107)
The article you linked too is interesting because:
"Storing a list of messages to send: whether it’s emails, SMS messages"
seems to be something like reddit does [1] & [2]. Is this the case:
[1] https://github.com/reddit/reddit/blob/master/r2/r2/lib/email... [2] https://github.com/reddit/reddit/blob/master/r2/r2/models/ma...
1) Install ActiveMQ (or my preferred option, ActiveMQ Apollo http://activemq.apache.org/apollo/).
2) Write an email script that subscribes to the message queue, and sends an email for each message received.
3) In the web app, publish a "send email" message to the message queue.
That's it - nothing more complicated required. Look at the number of libraries that use the Stomp protocol, and you can be up and running inside of a few minutes.
Spinning off a separate thread to perform this work is entirely sufficient and much simpler
I strongly disagree with this advice, if only because it's so incredibly easy to screw up from a security perspective. If you want to handle errors or other unexpected issues, doing so via spinning up background threads is going to lead you to a world of hacky pain.
One of the most inspiring articles I read about using queues is 5 subtle ways you’re using MySQL as a queue, and why it’ll bite you:
http://www.engineyard.com/blog/2011/5-subtle-ways-youre-usin...