Job Scheduling in Java - need tips and suggestions
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I don't know what is the best and simplest way to do these things. I saw that Timer and TimerTask can do similar things. But I don't know if those classes have any limitations.
I also looked at Quartz. But, it is too sophisticated and complex for my simple program.
Are there any other simple and reliable options out there ? If not, how do I learn about Timer and Timer Task to make my program.
Thanks in advance.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
David S Hansen wrote:how do I learn about Timer and Timer Task to make my program.
You google 'java timer tutorial'
Joanne
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Joanne Neal wrote:
David S Hansen wrote:how do I learn about Timer and Timer Task to make my program.
You google 'java timer tutorial'
I did that and all the tutorials are silly toy examples and nothing more. I am trying to avoid sophisticated stuff like cron4j and quartz. What do I do ?
Is there any book that explains Timer well with some good examples ?
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I feel that Timer and TimerTask are good enough for my purposes, but too basic for big jobs. I am thinking of learning a scheduler api, but I am not sure which one to select.
I have the following criteria to choose my api -
1 - Must be very easy to use - no complicated setup, no additional skills except java needed (ie NO xml, json, ant, maven etc)
2 - Should be popular among developers, mature, well maintained, have well documented API.
3 - Should have a lot of tutorials and/or books especially for beginners (ie those just beginning job scheduling)
Nice to have - Eclipse integration (if applicable)
Please help me to evaluate all the good options out there like cron4j, quartz, obsidian.
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hope this helps
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Junilu Lacar wrote:Of the three options you cited, I have only worked with Quartz, so take this with a grain of salt. cron4j seems to fit the bill for minimalism so you might want to start with that and work your way up to Quartz and/or Obsidian as your scheduling needs expand and get more sophisticated. From what I've seen with a cursory exploration of their website, Obsidian offers many features that make it easier to set up, manage, and monitor your jobs. Quartz is probably the more commonly used of the three and there are many references and tutorials on using it but there is still a bit of a learning curve involved, based on my experience.
Hope this helps
Yes, cron4j seems to fit my description. But, there is hardly any documentation, tutorial, or presence on forums like CodeRanch, StackOverflow, ExpertsExchange. So, I will have almost no help for cron4j. Quartz seems better in that respect. But its like using a pistol to kill a fly.
IMHO, in the end documentation and tutorials trump everything, given that features are ok and software is usable. So, can you tell me if the following is true -
Using Quartz is as simple as downloading the necessary file and adding the jars in that file to your project. There is nothing else to Quartz, besides learning how the API works.
There are no new/extra things like config files (xml, json). No ant or maven knowledge is necessary.
If that is true, then quartz is my choice. Obsidian sounded much better because it talked about doing away with xml config and such. But, its too new, unproven and has "0" support on public forums.
EDIT -
It looks like you need to know SLF4J as per sl4fj page and this tutorial
Is it really needed for all quartz projects ?
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
David S Hansen wrote:Yes, cron4j seems to fit my description. But, there is hardly any documentation, tutorial, or presence on forums like CodeRanch, StackOverflow, ExpertsExchange. So, I will have almost no help for cron4j.
I'm not so sure about that. The name would suggest that cron4j is a Java port of the Unix cron command (which, IMO, is a classic piece of minimalist software); and there is plenty of documentation about that around. As an old Unix SA, it would certainly be my first port of call if simplicity was my main concern.
My only question would be: what does it run? Unix cron is designed for running system commands/scripts, so I'm guessing that there's probably some sort of translation between a "name" in your 'crontab' (== config file) and a Java Runnable; but exactly what that is I don't know.
Winston
PS: I've just had a quick look at the documentation, and it seems perfectly reasonable; and very straightforward. Everything is based around a Task class which you extend. The API docs are a little weak, but there seems to be more than enough to get started in the main docs.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Winston Gutkowski wrote:
David S Hansen wrote:Yes, cron4j seems to fit my description. But, there is hardly any documentation, tutorial, or presence on forums like CodeRanch, StackOverflow, ExpertsExchange. So, I will have almost no help for cron4j.
I'm not so sure about that. The name would suggest that cron4j is a Java port of the Unix cron command (which, IMO, is a classic piece of minimalist software); and there is plenty of documentation about that around. As an old Unix SA, it would certainly be my first port of call if simplicity was my main concern.
My only question would be: what does it run? Unix cron is designed for running system commands/scripts, so I'm guessing that there's probably some sort of translation between a "name" in your 'crontab' (== config file) and a Java Runnable; but exactly what that is I don't know.
Winston
PS: I've just had a quick look at the documentation, and it seems perfectly reasonable; and very straightforward. Everything is based around a Task class which you extend. The API docs are a little weak, but there seems to be more than enough to get started in the main docs.
I guess its enough to get started. Lets compare the two API's on the basis of StackOverflow data -
Quartz -
Quartz questions
Quartz unanswered
Cron4j -
Cron4j Questions
Cron4j Unanswered
As of now -
Questions: Cron4j = 6, Quartz = 965
Unanswered: Cron4j = 3, Quartz = 259
fail rate: Cron4j = 50, Quartz = 27%
Looks like cron4j is a BIG loser in terms of support. I think that beginners need support the most, especially in the form of quick responses at any time of the day, something that one usually finds only in SO (Sorry coderanch) .
However, it is possible that cron4j is so simple and intuitive that people don't really need to ask questions and Quartz is super complicated.
My problem is that I have no way to be sure if the above line is true. If not, then cron4j might be a bad choice for a beginner.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
David S Hansen wrote:However, it is possible that cron4j is so simple and intuitive that people don't really need to ask questions and Quartz is super complicated.
My problem is that I have no way to be sure if the above line is true. If not, then cron4j might be a bad choice for a beginner.
Possibly, unless they
(a) already know cron.
(b) don't need great complexity.
in which case I suspect it would be a very natural choice. It seems like a pretty straightforward port of the command to me.
Winston
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Junilu Lacar wrote:David, can you be more specific about the details of the job(s) are you trying to schedule? I'm starting to think that we could go into a fairly long discussion about the pros and cons of each of these frameworks. If we had a better idea of what the exact problem was, it would help limit the scope of the discussion and get to a decision quicker.
I want to perform simple tasks (eg. download file, upload, etc) at particular times in a day, everyday. I want to have the power to change these times depending on my needs on a particular day. I need a scheduler for this purpose.
Is this information enough answer the question?
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I've used the Quartz API in quite a complex project. And Quartz is fairly simple, right from setting it up to extending the API for customizations.
And it is very stable and reliable in terms of job executions. Maintains its own DB which enables easier monitoring or altering of jobs.
My say would be Quartz.
If at all you decide to use the Quartz API, we can then take forward your questions.
Thanks and Regards,
-------------------------------------------------------------------------------------
Komal Renu | [email protected] | www.infocepts.com
-------------------------------------------------------------------------------------
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
David S Hansen wrote:I want to perform simple tasks (eg. download file, upload, etc) at particular times in a day, everyday. I want to have the power to change these times depending on my needs on a particular day. I need a scheduler for this purpose.
Is this information enough answer the question?
Then I'd say that scheduling is not the big problem here. If this was my project, I'd probably just use the Spring Framework's TaskScheduler and a CronTrigger. However, of the choices you have narrowed it down to, I would probably go with cron4j because it seems to be the simplest and most straightforward of the three.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Junilu Lacar wrote:
David S Hansen wrote:I want to perform simple tasks (eg. download file, upload, etc) at particular times in a day, everyday. I want to have the power to change these times depending on my needs on a particular day. I need a scheduler for this purpose.
Is this information enough answer the question?
Then I'd say that scheduling is not the big problem here. If this was my project, I'd probably just use the Spring Framework's TaskScheduler and a CronTrigger. However, of the choices you have narrowed it down to, I would probably go with cron4j because it seems to be the simplest and most straightforward of the three.
Now the choice is between cron4j and ScheduledThreadPoolExecutor. What should I take ?
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Why do you want a GUI to be involved? Most scheduled jobs are of the non-GUI variety, making them amenable to be run by trusty old cron invoking a JVM.
If I found these lacking I'd probably go for Quartz, simply because it seems the standard library for the job, so I'd assume it's well-tested and I can find someone to answer questions.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
David S Hansen wrote:
If that is true, then quartz is my choice. Obsidian sounded much better because it talked about doing away with xml config and such. But, its too new, unproven and has "0" support on public forums.
You describe Obsidian as too new and unproven. Obsidian Scheduler has been around for more than 2 years, so it is newer than some of these solutions, but is already in use by thousands including Fortune 500 companies. As far as public forums, we provide free support by phone, email and live chat in addition to our extensive wiki that documents the scheduler extensively. As new issues and questions come up and are addressed, the wiki is extended. Try it out we think you'll be most impressed.
| New rule: no elephants at the chess tournament. Tiny ads are still okay. The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |








