Using Quartz with SOA Suite 11g

Already in 2006 Clemens posted on scheduling BPEL processes. More recently with BPEL in SOA Suite 11g a bug ( 8927175: PROVIDE QUARTZ SCHEDULER) was submitted. The rquest text:

The product does not have schedular to schedule BPEL processes. Need to schedule the BPEL processes through SOA11G and not through unsupported softwares(Quartz).

And the business need:

Some processes need to be scheduled at a particular time and at a particular day and should not be started Manually, increases the maintenance cost of the software.

These together indicate a clear need to schedule reoccurring processes. Although I’m not so sure that this functionality should be provided by this platform. One could see advantages in centralizing all scheduling task. There a good commercial product available for cases like that (Redwood’s Cronacle for example).

On Oracle Technet there is a good document on Configure a SOAScheduler for a composite in SOA Suite 11.

One Job, multiple Schedules

We need a Class that implements Job. Something like:

package net.deltalounge.quartzdemo;
 
import java.util.Map;
 
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.SchedulerException;
 
public class DemoJob implements Job {
    public DemoJob() {
        super();
    }
 
  public void execute(JobExecutionContext context)
     {
      Map dataMap = context.getJobDetail().getJobDataMap();
      RunMeTask task = new RunMeTask();
      String someString ="init";
      someString = context.getTrigger().getName();
      System.out.println("Quartz demo output: "+someString);      
    }
}

And we need a Class that creates and starts the Scheduler. This Class can also schedule the jobs. Here we actually see that although one Job Class is enough we need to declare mutiple JobDetails.

package net.deltalounge.quartzdemo;
 
import java.util.Map;
 
import org.quartz.CronTrigger;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.impl.StdSchedulerFactory;
 
public class QuartzAppCronTrigger {
  public static void main( String[] args ) throws Exception
      {
        //scheduler task details
        JobDetail job = new JobDetail();
        job.setName("someJob");
        job.setJobClass(DemoJob.class);
        //
        JobDetail job2 = new JobDetail();
        job2.setName("someOtherJob");
        job2.setJobClass(DemoJob.class);
 
        //configure scheduler time
        CronTrigger trigger = new CronTrigger();
        trigger.setName("someJobTrigger");
        trigger.setCronExpression("0/30 * * * * ?");
 
        //configure scheduler time 2
        CronTrigger trigger2 = new CronTrigger();
        trigger2.setName("someOtherTrigger");
        trigger2.setCronExpression("0/20 * * * * ?");
 
        //create the schedule
        Scheduler scheduler = new StdSchedulerFactory().getScheduler();
        scheduler.start();
        scheduler.scheduleJob(job, trigger);
        scheduler.scheduleJob(job2, trigger2);
      }
 
}

If you don’t define multiple jobs prepare for an error like:

Exception in thread "main" org.quartz.ObjectAlreadyExistsException: Unable to store Job with name: 'someJob' and group: 'DEFAULT', because one already exists with this identification.
	at org.quartz.simpl.RAMJobStore.storeJob(RAMJobStore.java:222)
	at org.quartz.simpl.RAMJobStore.storeJobAndTrigger(RAMJobStore.java:195)
	at org.quartz.core.QuartzScheduler.scheduleJob(QuartzScheduler.java:732)
	at org.quartz.impl.StdScheduler.scheduleJob(StdScheduler.java:265)
	at net.deltalounge.quartzdemo.QuartzAppCronTrigger.main(QuartzAppCronTrigger.java:36)

5 thoughts on “Using Quartz with SOA Suite 11g

  1. Edwin Biemond

    Can Quartz handle WebLogic Clusters, The default Timer for WebLogic is CommonJ and this one have two implementations, single and cluster.

    I am waiting for EJB 3.1 which has supports for Timers.
    thanks

  2. PeterPaul Post author

    Hi Edwin, Quartz can handle clustering, however it requires the JDBC-Jobstore for that case. We haven’t tested it with an Weblogic cluster. Within a few weeks we’ll have a Weblogic cluster available, and we will test this asap.

    hth,
    Peter Paul

  3. Matt Wright

    Rubicon Red provide an out of the box scheduler for the Oracle SOA Suite, enabling you to schedule:

    – Execution of a synchronous web service
    – Execution of one way or two way asynchronous web service
    – Publication of an EDN event to the SOA Suite Event Delivery Network

    It provides full cluster support (it uses Coherence to manage this)

    See http://www.rubiconred.com/scheduler for further details

  4. Nithin Saseendran

    Hi Peter,

    We are encountering an issue with Quartz scheduler at clustered environment. Its not working and loading the default properties, From the logs, we could see that:

    09 Feb 2017 15:18:48,725 INFO optimUSTAllocationSchedule_Worker-1 org.quartz.core.QuartzScheduler – Scheduler meta-data: Quartz Scheduler (v2.1.1) ‘DefaultQuartzScheduler’ with instanceId ‘NON_CLUSTERED’
    Scheduler class: ‘org.quartz.core.QuartzScheduler’ – running locally.
    NOT STARTED.
    Currently in standby mode.
    Number of jobs executed: 0
    Using thread pool ‘org.quartz.simpl.SimpleThreadPool’ – with 10 threads.
    Using job-store ‘org.quartz.simpl.RAMJobStore’ – which does not support persistence. and is not clustered.

    09 Feb 2017 15:18:48,727 INFO optimUSTAllocationSchedule_Worker-1 org.quartz.impl.StdSchedulerFactory – Quartz scheduler ‘DefaultQuartzScheduler’ initialized from default resource file in Quartz package: ‘quartz.properties’

    Its loading the default properties. How can we avoid this error?

    Regards,
    Nithin

  5. PeterPaul Post author

    Hi Nithin,

    Did you configure Quartz to run clustered? The log says:
    ‘DefaultQuartzScheduler’ with instanceId ‘NON_CLUSTERED’

Leave a Reply

Your email address will not be published. Required fields are marked *