Quartz is a very popular scheduler library for Java. It is commonly used for periodically executed tasks. We use it in our plugin, all worked fine, until a customer complained about JIRA filter subscriptions being sent twice whenever the plugin is active.
And here is the full story…
A while ago we needed this kind of task in the context of a JIRA plugin. To get a Scheduler instance we simply used the following code:
Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
Our Job was periadically executed and everything seemed to be fine … well, until a customer complained …
So the next try was the atlassian-scheduler package bundled with JIRA and other Atlassian applications:
Scheduler scheduler = com.atlassian.scheduler.SchedulerLauncher.getScheduler();
Unfortunately the fix didn’t fix the problem… The time had come for a working solution! JIRA contains a class “com.atlassian.jira.scheduler.JiraSchedulerFactory” that does the trick:
JiraSchedulerFactory schedulerLauncher = new JiraSchedulerFactory(); scheduler = schedulerLauncher.getScheduler();
One last thing: Don’t forget to either implicitly or explicitly import the package “com.atlassian.jira.scheduler” to your plugin (OSGi Bundle) to avoid ClassNotFoundExceptions.