• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java Scheduler - Quartz API?

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Folks,
First of all I do not know if this I am in the right form, if it is not then I apologize and please direct me to the right one.

Here's my requirement: I need a Java Scheduler. Something that is supposed to check the database every minute (that sounds expensive to me, would love your inputs) and see if there are any jobs for that minute.
And if there is a job to be run that minute, get the information pertinent to executing the job and add the job to a queue. This job will be delegated to a worker that will have its own thread and will run the job.
I did some research and saw the Quartz framework.
Now my questions:
*I was given this requirement. For the domain I am on, I do not think I need a task to be hitting the database every minute and check for a job.

*If it is not a big deal to do it in this way, can i use Quartz in some fashion?

*If not for this solution or Quartz, what is the best way to execute this need. Wherein an administrator will go in and add tasks and the time in the database and will expect the application to fire it at that instant.

I know I've given a very long question. I could not help it; I needed to get a validation on the design and see if some of you gurus can help me with a sound solution.

Thanks for all your help.
 
Ranch Hand
Posts: 686
Mac
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Raghu Nathan:
every minute and check for a job.

*If it is not a big deal to do it in this way, can i use Quartz in some fashion?



Yup you can do this in Quartz. But as you said it is too much for any project to fire a job every minutes.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Quartz can help with this, but so -probably- could the java.util.Timer and TimerTask classes (which are my preferred vehicle of choice for scheduling).

The more interesting part might be how to cancel and reschedule changed tasks, but the concurrency classes introduced in Java 5 (Future, Executor, ExecutorService) can handle that.

As to querying the DB every minute, I wouldn't be too concerned. Modern DBs routinely handle hundreds of calls a minute, one more isn't going to make much of a difference. (Assuming that the query in question doesn't take a long time to run, of course.)
 
Raghu Nathan
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your responses.
I am sorry I could not check your replies earlier.

Let me give it a shot and I'll let you guys know how it plays out.
 
Raghu Nathan
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks folks;
I used Quartz and it was a breeze. I highly recommend Quartz to those wanting to schedule. Why reinvent the wheel??
 
reply
    Bookmark Topic Watch Topic
  • New Topic