Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java scheduled job

 
ben oliver
Ranch Hand
Posts: 375
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ben,

Have you looked into Quartz framework? Here's a link if you are interested -> Quartz Scheduler
 
ben oliver
Ranch Hand
Posts: 375
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 176
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alternatively, you could use the EJB timer service.

Here is an article explaining how to do this in a J2EE 1.4 server.

My book, Java EE 5 Development Using GlassFish Application Server covers how to do this with Java EE 5.

Hope that helps,
David
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic