Which scheduler to use?


I need to use a scheduler to start a task once a day to import CSV files into a plugin’s tables. But I’m a bit lost on which scheduler to use… SAL? Atlassian Scheduler? PluginScheduler?

For the record, I tried with PluginScheduler, but the task is not launched. Maybe I’m missing something about component registration.

public class ComposanteSchedulerImpl implements ComposanteScheduler, LifecycleAware {

    private static final Logger log = LoggerFactory.getLogger(ComposanteSchedulerImpl.class);
    private long interval = 50000L;      // default job interval (5 sec)
    private static final String JOB_NAME = ComposanteSchedulerImpl.class.getName() + ":job";
    /* package */ static final String KEY = ComposanteSchedulerImpl.class.getName() + ":instance";

    private final PluginScheduler scheduler;

    public ComposanteSchedulerImpl(@ComponentImport PluginScheduler scheduler) {
        this.scheduler = checkNotNull(scheduler);

    public void onStart() {

    public void reschedule(long interval) {
        this.interval = interval;

                JOB_NAME,                   // unique name of the job
                TacheImportationCSV.class,     // class of the job
                new HashMap<String, Object>() {{
                    put(KEY, ComposanteSchedulerImpl.this);
                }},                         // data that needs to be passed to the job
                new Date(),                 // the time the job is to start
                interval);                  // interval between repeats, in milliseconds
        log.info(String.format("Import Casewise %dms", interval));


And the implementation:

public class TacheImportationCSV implements PluginJob {

    private final ActiveObjects ao;

    public TacheImportationCSV(@ComponentImport ActiveObjects ao) {
        this.ao = checkNotNull(ao);

    public void execute(Map<String, Object> jobDataMap) {

The current recommended way is the new shiny atlassian scheduler since it handles cluster scheduling. There’s an example implementation of it at https://bitbucket.org/cfuller/atlassian-scheduler-jira-example/src/master/