Simple Quartz job, reading cron job expression from xml file. {RamJobStore} 1

This blog is to show how to make a Quartz job, reading cron job expression from xml file. Its a ram job store example i.e. it will not put the information inside any DB.


Ok, lets’s start first making the quartz-job.xml

<?xml version="1.0" encoding="UTF-8"?>
            <description>This is File Listener Job</description>
                <!-- It will run every 10 seconds -->
                <cron-expression>0/10 * * * * ?</cron-expression>

Now we will make a file, in which we will give the reference of quartz-job.xml and also tell the quartz-module that we want it a ramjob store.

# property file for quartz << Ram job store >>
org.quartz.scheduler.instanceName = MyScheduler
org.quartz.threadPool.threadCount = 3
org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore
org.quartz.plugin.jobInitializer.wrapInUserTransaction = true
org.quartz.plugin.jobInitializer.class =org.quartz.plugins.xml.XMLSchedulingDataProcessorPlugin
org.quartz.plugin.jobInitializer.fileNames = quartz-config.xml
org.quartz.plugin.jobInitializer.failOnFileNotFound = true

Ok, here we finished with the configuration part of the quartz-module.


Now let’s start making the job and factory classes.

Here i am making use of controller class which is responsible for making the SchedulerFactory.
Below is the code:

import org.quartz.Scheduler;
import org.quartz.SchedulerFactory;
import org.quartz.impl.StdSchedulerFactory;

import com.quartz.module.exception.QuartzModuleException;

public class QuartzController {

    private static final QuartzController controller = new QuartzController();
    private Scheduler scheduler;
    private QuartzController(){}

    public static QuartzController getInstance(){
        return controller;

    public void initialize(){
        try {
            SchedulerFactory factory = new StdSchedulerFactory(<strong>""</strong>);
            scheduler = factory.getScheduler();
        } catch (Exception e) {
            throw new QuartzModuleException(e.getMessage(), e.getCause());

In above code we gave reference of file, which make use of quart-job.xml file to register the job.
Below is the code of FileListenerJob class.

package com.quartz.module.job;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import com.filemaker.reader.UploadedFileListener;

public class FileListenerJob implements Job{

    public void execute(JobExecutionContext context)
            throws JobExecutionException {
        UploadedFileListener fileListener = new UploadedFileListener("[a-z]");
        System.out.println("File Listener Job : No Of Files Uploaded :: " + 


One comment on “Simple Quartz job, reading cron job expression from xml file. {RamJobStore}

  1. Reply caleb Aug 12,2013 10:35 pm

    Thank you for this blog. That’s almost all I can declare. You almost certainly have made this web site into some thing thats eye opening and important. You clearly know so much about the subject, youve included so many facets. Great products from this the main internet. Once more, thank you for this web site.

Leave a Reply