What's the best way to send scheduled e-mails from a Java-based web app?
I'm implementing a little web application using Java and the Wicket framework. Each user of the application has a list of events, each of which has a "due time."
I would like to send an e-mail to the user when any of his/her events开发者_JAVA百科 is due. How should I implement this notification feature?
I can write a separate service to check the database every minute and send the e-mails; I just want to see if there is an easier and better way to do it.
I think a seperate prozess that periodically checks for emails to be send is the best option here. You could use the Quartz sheduler or write a job that gets started by the OS periodicaly.
Another, rather hacky option would be to extend the wicket request cycle processor and do email check there. But this would rely on the fact that you actually get requests often enough to not miss an check intervall. I would only choose this if you can not create jobs on the OS level for some reason.
精彩评论