Category Archives: Open Source

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)

A pre-JavaOne peek into the future of Java

In this week just before JavaOne and Oracle OpenWorld the topic “the future of Java” keeps coming up again and again. Today the tweets coming out of the Oracle ACE Director briefing, that some how aren’t affected by a non-disclosure agreement, seem strong and positive: Ranging from Extremely passionate and very impressive, and incredibly passionate address to amazingly open words. Resulting in the statement Oracle is on the good side of the force… as far as Java is concerned. As close as we mere mortals can get at this point in time…

In one of the tweets Thomas Kurian is quoted:

After my keynote, there is no longer any confusion about the Java feature roadmap.

To see for yourself what the future of Java looks like, watch Thomas Kurian’s keynote live via the stream on JavaOne and Java Develop. To be continued…

Note that the Java Champions have joined the Oracle ACE Directors. As was stated here this significantly raised the number of Eclipse users 😉

Java EE or Spring

Recently I read an extensive blogpost by Frans van Buul on Spring and Java EE. As he points out there are some false arguments in favor of the Spring Framework. It is stated that:

Many of the arguments that have traditionally been brought forward in favor of Spring are invalid or outdated, because they target disadvantages of J2EE 1.4 and prior versions, rather than Java EE 5/6. … the original argument that this is not supported by Java EE is simply gone, and the remaining argument, if present, is much weaker.

If you’re in a position where evaluating these alternatives read the entire blogpost. Generally speaking there is no best way to go. Both are viable frameworks for writing Java applications.

The choice should be made by taking into account the particular requirements and technology strategy of the organizations building and using the application.

If there’s an opportunity we’ll see if we can come up with some rules of thumb for the selection.

Some jBPM, JPA, Hibernate insights

jBPM

jBPM

Few days ago a colleague published an interesting blogpost on jBPM, JPA, and Hibernate. The post was noticed by Tom Baeyens, who until late March 2010 was the project lead for jBPM at JBoss.
Of course JBoss restates their commitment to advancing the jBPM project, but it will be very interesting to see what will come from Tom Baeyens’s new initiative…