How to create a java scheduled job inside a j2ee application EAR file ? I want to bundle it in a EAR and deploy it. I heard about TimerTask, but people usually implement it as a servlet listener, which means when servlet or server is restarted the job is triggered. But I don't want that to happen, I want the job purely run at certain day/time. Can I do that ?
Is there any other way to schedule a job without being affected by server or application restart, assuming I still want to bundle it with a EAR ?
I don't like to use cronjob though, so that's not an option.
Thank you.
Shailesh Kini
Ranch Hand
Joined: Oct 17, 2001
Posts: 153
posted
0
Hello Ben,
Have you looked into Quartz framework? Here's a link if you are interested -> Quartz Scheduler
Shailesh Kini.
ben oliver
Ranch Hand
Joined: Mar 28, 2006
Posts: 369
posted
0
Originally posted by Shailesh Kini: Hello Ben,
Have you looked into Quartz framework? Here's a link if you are interested -> Quartz Scheduler
Thanks. I heard of that but never used it before. My major concern is --
I know both "TimerTask" and "Quartz" can be scheduled task. But
1) which one can be bundled with a j2ee application, and does NOT have to be triggered automatically when the application is deployed/redeployed or server is rebooted ? i.e. I want it to run using its own scheduler without being affected by the j2ee server reboot or application redeployment.
2) In addition to run at its chedule, which one also has the flexibility to be triggered upon request ?
David Heffelfinger
author
Ranch Hand
Joined: Jul 08, 2004
Posts: 176
posted
0
Alternatively, you could use the EJB timer service.
Here is an article explaining how to do this in a J2EE 1.4 server.
Author, <a href="http://www.packtpub.com/java-ee5-development-with-netbeans-6" target="_blank" rel="nofollow">Java EE 5 Development with NetBeans 6</a>
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.