-
1. Re: Can you have an app run every 5 minutes?
hamffjs Jul 26, 2006 4:46 PM (in response to ericchile)I don't know if it would be the best approach, but you do set up a Servlet that loads on startup and schedules a TimerTask instance using a Timer instance.
For example, in the init method of your Servlet
public void init() throws ServletException {
Timer timer = new Timer();
// This class needs to extend the abstract TimerTask class
// The code to be executed needs to put in the public void run() method
RepeatableTask repeatableTask = new RepeatableTask();
long interval = 1000 * 60 * 5; // 5 minutes in millis
// this will cause the task start immediately and repeat every 5 minutes
timer.scheduleAtFixedRate(repeatableTask, 0, interval);
}
Hope that helps. -
2. Re: Can you have an app run every 5 minutes?
jaikiran Jul 27, 2006 5:20 AM (in response to ericchile)You can use a Scheduler(which is nothing but an MBean) in JBoss. The Scheduler will act like a service and will be started when you start jboss. You can configure the Scheduler to invoke your class every 'x' mins.
Have a look at:
http://wiki.jboss.org/wiki/Wiki.jsp?page=Scheduler