Ron Ziroby Romero
Ron Ziroby Romero

Reputation: 9459

Should I use a Quartz XML job file or configure jobs with code

I'm picking up Quartz Scheduler for a new project. I've use Quartz before, and I configured it using an XML job file. Now I look at the current Quartz documentation, and all the examples are code snippets. Is the XML job file deprecated? Should I do my job scheduling and configuration in code?

Upvotes: 0

Views: 793

Answers (1)

Robert Moskal
Robert Moskal

Reputation: 22553

The non java folks always say that java is way too XML-centric :). I would say it depends on a number of things. Do you use other java frameworks, like say Spring? If so, have you moved away from the XML based configurations for that? That would be an argument for moving away from XML configuration for quartz as well.

One of the advantages claimed for external configuration files is that in a compiled language no compilation is required to change the job configurations (and so can be done by a non-developer). One can simply update the appropriate configuration file and restart the application.

How true this is depends on how your app is deployed. Often deployment of all the application artifacts happens as part of a build process (if you create a war with maven and push to a server or a git repository). So having separate configs for the job might not really be an advantage.

However, I could imagine an app deployed to a container that supports something like mbeans, so that the you could provide a simple management interface for scheduling your jobs. You could allow business people to control the schedule, with minimal effort and impact on your codebase.

If you use the code based configuration, you won't be able to change the schedule of the jobs without a recompilation and redeployment. You could do it by externalized the settings somehow, but then you'd be just be reinventing the external configuration files.

Upvotes: 2

Related Questions