Hello good people
I'm wondering what the best protocol is for sending email reminders to users who need to do something.
Do coders usually have the application run through the users and their status every day at a certain time --
so the application checks for a time?
this is dependent on the reason that leads to a user notification and the application, I think.
What triggers an email notification? Is it in direct response to a user interaction? Or do you just have to perform necessary checks in a regular interval? How often do you have to do this? Regular checks may depend on the type of your application, because you have to think about a scheduler implementation to trigger the checks. Is the application running permanently, so that it can take care of checks itself? Do you need external scheduler like cron in UNIX/Linux? Is it critical if you miss an interval because of a system downtime? etc. etc.
If you have answers to these questions it's time to think about more concrete solutions ;-)
posted 10 years ago
The application will be running continuously. The requirement is to send an email weekly to each user who still needs to fill out a form (once they finish a flag in the db will be tripped to indicate they are done).
Perhaps a cron is the way to go.
No, its nothing critical related to system maintenance.
if the application is running permanently I'd prefer to NOT depend on external services like cron. It's not a big deal to configure jobs with it, but I've often seen that cron jobs have been forgotten to setup or nobody noticed that the job didn't work any longer because of some problems and so on.
If you're application is running inside a servlet container or a full application server, it's likely that you already have a access to some kind of timer or scheduler mechanism (at least with most J2EE/JEE containers). If it's a standalone application I would recommend the Quartz library. It's very powerful and can handle all kinds of scheduling timings. All you have to do yourself is create some kind of task to perform the necessary database checks and notify the corresponding user via email and the scheduler will take care of running the task in intervals or at specific time.
Does Tomcat have an internal scheduler? I couldn't find one and quartz has a nice servlet initialiser so you can start it within the web application and I liked that. All the other setting were in a properties and XML file so it was relatively simple.
Tomcat uses Quartz internally. You can see it running additional scheduler threads with Quartz, although I don't know what for what exactly Tomcat uses it. Anyway, I'm pretty sure you can't use it directly from within your web app. Application servers like Glassfish or JBoss provide a timer service for applications, but I think this would be overkill as Quartz is a perfect solution as Sean pointed out.
Water! People swim in water! Even tiny ads swim in water: