I am currently using Quartz Scheduler for asynchronous tasks such as sending an email when an exception occurs, sending an email from the web interface, or periodically analyzing traffic.
Should I use a message queue for sending an email? Is it any more efficient or correct to do it that way? The scheduler approach works just fine.
If I use a queue and the email failed to send, is it possible for the queue to retry sending the email at a later time? The queue approach looks simpler than the scheduler for tasks that need to happen immediately, but for scheduler tasks, the scheduler still, unless there is more to the queue than I am aware of.
I have not yet used JMS, so this is what I have read.
Walter
They are really different and it depends on the purpose and frequency you want to send an email.
The scheduler generates an event that is time based and then runs some code to send an email.
A queue has no way of triggering an event, it needs to have a message put on it from somewhere and then a MessageListener send an email.
To answer your question a queue is a good instrument to send an email if
the queue if the operation fails,
even though SMTP does not know if
the email reached it’s destination.
the queue.
The scheduler can run some java code at a certain interval and therefore generates temporal events.
If you want to send periodic emails then the scheduler is the way to go.
If you go with the scheduler then you should have the scheduler put a message on a queue.
If not then you need to have some other trigger put a message on the queue.