how to run a gwt servlet automatically in some particular time interval?
Please help me about this issue...
In my application i have calender where user can set the 开发者_StackOverflow社区events for particular day.. this event info is store in database.... now i want my application to automatically send an email to that user on that assigned day....
You don't explititly need the Quartz API for such a simple timer task. For this java.util.TimerTask is perfectly suitable.
You have to use scheduler(quartz).Most of the applications are using that.Particularly for sending mails.
http://www.roseindia.net/quartz/index.shtml
http://www.quartz-scheduler.org/
https://quartz.dev.java.net/
You can schedule the scheduler to do some action in particular time interval.
Your servlet is running on the back-end. So all you need is to create an endless loop which is regulary checking if an email needs to be send out.
Something like this:
public void run()
{
isRunning = true;
while (isRunning)
{
performSomething();
try
{
Thread.sleep(someInterval);
}
catch (InterruptedException e)
{
isRunning = false;
}
}
Where the performSomething(); method is a synchornized method:
public synchronized void performSomething()
How about using cron jobs, you can call URLs with cron job which can be your servlet that handle the logic.
精彩评论